Topics | Search Log Out | Register | Edit Profile
Hide Clipart | Banned/Unbanned User Log | Moderator Login History | Thread Delete/Move Log | Last 30 mins | 1 | 2
Calling SQL Experts

Chalanachithram.com DB » New TF Industry Related » Archive through August 11, 2016 » Calling SQL Experts « Previous Next »
Author Message
 

Driverramudu
Hero
Username: Driverramudu

Post Number: 16905
Registered: 02-2009
Posted From: 166.170.14.26

Rating: 
Votes: 2 (Vote!)

Posted on Wednesday, August 10, 2016 - 10:27 pm:       

Banam

Chk ur mail
Driving is my PASSION.
Ball or Bimmer does not matter.
 

Banam
Hero
Username: Banam

Post Number: 12323
Registered: 12-2011
Posted From: 209.203.79.108

Rating: N/A
Votes: 0 (Vote!)

Posted on Wednesday, August 10, 2016 - 09:06 pm:       

Database is Oracle..
Green Bay PACKERS ||San Antonio SPURS ||Sachin Ramesh TENDULKAR
 

Banam
Hero
Username: Banam

Post Number: 12322
Registered: 12-2011
Posted From: 209.203.79.108

Rating: N/A
Votes: 0 (Vote!)

Posted on Wednesday, August 10, 2016 - 08:54 pm:       


Driverramudu:

driver.ramudu79 at gmail




Sent bro Sample data inserts.
Green Bay PACKERS ||San Antonio SPURS ||Sachin Ramesh TENDULKAR
 

Banam
Hero
Username: Banam

Post Number: 12321
Registered: 12-2011
Posted From: 209.203.79.108

Rating: N/A
Votes: 0 (Vote!)

Posted on Wednesday, August 10, 2016 - 08:51 pm:       


Driverramudu:

Banam

If u need query then
Send the sample data to my email
To driver.ramudu79 at gmail

I will reply to that




Sure bro..
Green Bay PACKERS ||San Antonio SPURS ||Sachin Ramesh TENDULKAR
 

Driverramudu
Hero
Username: Driverramudu

Post Number: 16903
Registered: 02-2009
Posted From: 166.170.14.26

Rating: N/A
Votes: 0 (Vote!)

Posted on Wednesday, August 10, 2016 - 08:37 pm:       

Banam

If u need query then
Send the sample data to my email
To driver.ramudu79 at gmail

I will reply to that
Driving is my PASSION.
Ball or Bimmer does not matter.
 

Driverramudu
Hero
Username: Driverramudu

Post Number: 16902
Registered: 02-2009
Posted From: 166.170.14.26

Rating: N/A
Votes: 0 (Vote!)

Posted on Wednesday, August 10, 2016 - 08:34 pm:       

Banan


Use CTE and outer apply operator
Then u will get what you want :-)
Driving is my PASSION.
Ball or Bimmer does not matter.
 

Banam
Hero
Username: Banam

Post Number: 12320
Registered: 12-2011
Posted From: 209.203.79.108

Rating: N/A
Votes: 0 (Vote!)

Posted on Wednesday, August 10, 2016 - 08:31 pm:       


Symbol_of_king:

you need to use lead or lag analytic functions to achieve this.




Tried this bro, but kudaraledhu because of EXP records existing in middle. There can be multiple of them some times...
Green Bay PACKERS ||San Antonio SPURS ||Sachin Ramesh TENDULKAR
 

Abcdefghij
Hero
Username: Abcdefghij

Post Number: 18998
Registered: 02-2007
Posted From: 68.42.113.64

Rating: N/A
Votes: 0 (Vote!)

Posted on Wednesday, August 10, 2016 - 08:26 pm:       

sorry ignore my post

i did not read about renewal_cnt and thought it was pivot
Post by Knf: bittter annai, welcome RS prakasam varaku madi, Prakasm nunchi UA vaaraku meeedi
http://www.chalanachithram.com/cgi-bin/discus/show.cgi?tpc=115&post=5144373#POST5144373
 

Symbol_of_king
Junior Artist
Username: Symbol_of_king

Post Number: 266
Registered: 12-2010
Posted From: 72.219.244.175

Rating: N/A
Votes: 0 (Vote!)

Posted on Wednesday, August 10, 2016 - 08:20 pm:       

you need to use lead or lag analytic functions to achieve this.
 

Abcdefghij
Hero
Username: Abcdefghij

Post Number: 18997
Registered: 02-2007
Posted From: 68.42.113.64

Rating: N/A
Votes: 0 (Vote!)

Posted on Wednesday, August 10, 2016 - 08:19 pm:       

its multi step process if i understood your requirement

1. u need to create dynamic pivot, store below columns in temp table
REG_ID||Pkg_DES||PRD_DESC||EVENT_DATE||event_type_cd||renewa
2. then you need to apply your business rules for is_conversion & is_renewal etc on above temp table

https://www.mssqltips.com/sqlservertip/2783/script-to-create -dynamic-pivot-queries-in-sql-server/
Post by Knf: bittter annai, welcome RS prakasam varaku madi, Prakasm nunchi UA vaaraku meeedi
http://www.chalanachithram.com/cgi-bin/discus/show.cgi?tpc=115&post=5144373#POST5144373
 

Banam
Hero
Username: Banam

Post Number: 12319
Registered: 12-2011
Posted From: 209.203.79.108

Rating: N/A
Votes: 0 (Vote!)

Posted on Wednesday, August 10, 2016 - 08:11 pm:       

Hi Guys, I have the requirement like this below

REG_ID || PACKAGE_DESC || PRODUCT_TYPE_DESC || EVENT_DATE || event_type_cd
1 || CC || trail || 12-12-2012 || new sub
1 || CC || trail || 12-13-2012 || exp
1 || CC || PAID || 12-14-2012 || upsell
1 || CC || PAID || 12-15-2012 || exp
1 || CC || PAID || 12-16-2012 || renewal
1 || CC || PAID || 12-17-2012 || renewal
1 || aa || trail || 12-12-2012 || new sub
1 || aa || trail || 12-13-2012 || exp
1 || aa || PAID || 12-14-2012 || renewal
1 || aa || PAID || 12-15-2012 || renewal
1 || aa || PAID || 12-16-2012 || upsell
1 || aa || PAID || 12-17-2012 || renewal

The OutPut i need is like below

REG_ID||Pkg_DES||PRD_DESC||EVENT_DATE||event_type_cd||renewa l_cnt||is_ren|| is_conv
1 || CC || trail || 12-12-2012 || new sub || 0 || 0 ||0
1 || CC || trail || 12-13-2012 || exp || 0 || 0 ||0
1 || CC || PAID || 12-14-2012 || upsell || 0 || 0 || 1
1 || CC || PAID || 12-15-2012 || exp || 0 || 0 || 1
1 || CC || PAID || 12-16-2012 || renewal || 1 || 1 || 0
1 || CC || PAID || 12-17-2012 || renewal || 2 || 1 || 0
1 || aa || trail || 12-12-2012 || new sub || 0 || 0 || 0
1 || aa || trail || 12-13-2012 || exp || 0 || 0 || 0
1 || aa || PAID || 12-14-2012 || renewal || 0 || 0 || 1
1 || aa || PAID || 12-15-2012 || renewal || 1 || 1 || 0
1 || aa || PAID || 12-16-2012 || upsell || 2 || 1 || 0
1 || aa || PAID || 12-17-2012 || renewal || 3 || 1 || 0

- Conversion Logic :- If a PRD_DESC is changed from Trail to Paid for the 1st time, then it is called CONVERSION product
- Renewal Logic :- If a Paid Product is renewed from Paid to Paid, then it is called RENEWAL product

- renewal_cnt should start only at the PAID to PAID product. If the PAID to PAID is having event_type_cd as exp then the counter shouldn't increment. If the trail to paid is having event_type_cd as renewal then also it should be zero only. the event's are ordered by event_date

- is_conv should be set to 1 for the 1st Trail to Paid product.

- is ren should be set to 1 for the paid to paid product.

Does someone have the idea how to achieve this?}
Green Bay PACKERS ||San Antonio SPURS ||Sachin Ramesh TENDULKAR

Add Your Message Here
Post:
Bold text Italics Underline Create a hyperlink Insert a clipart image HASH(0x9ccc4d0){Movie Clipart}
Show / hide regular icons selection options

Click on following links to open cliparts by Alphabetical Order

 A   B   C   D   E   F   G   H   I   J   K   L   M  

N   O   P   Q   R   S   T   U   V   W   X   Y   Z  

Show / Hide Filmy icons selection options

Click on following links to open cliparts by Alphabetical Order

  A   B   C   D   E   F   G   H   I   J   K   L   M  

N   O   P   Q   R   S   T   U   V   W   X   Y   Z  

Username: Posting Information:
This is a public posting area. Enter your username and password if you have an account. Otherwise, enter your full name as your username and leave the password blank. Your e-mail address is optional.
Password:
E-mail:
Options: Enable HTML code in message
Automatically activate URLs in message
Action: