Author |
Topic |
bmsra79
Starting Member
24 Posts |
Posted - 2013-01-29 : 11:28:28
|
I have a View like below:FirstName,LastName,Createdate,CustomerID,Date1,Date2,SaleIDKurt,Russel,15-Mar-06,201,,,John,Mason,1-Jan-05,101,15-Jan-89,,5001John,Mason,1-Jan-05,101,15-Jan-90,25-Feb-90,2001Expected Output:FirstName,LastName,Createdate,CustomerID,Date1,Date2,SaleID,Flag1,Flag2,Kurt,Russel,15-Mar-06,201,,,,0,0,John,Mason,1-Jan-05,101,15-Jan-89,,5001,1,0,John,Mason,1-Jan-05,101,15-Jan-90,25-Feb-90,2001,2,1,I want to create 2 Flags that increment the count based on recurrence of Date1, Date2 for same Customer. |
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2013-01-29 : 11:38:02
|
something like this:SELECT firstname, lastname, date1, date2, row_number() over(partition by firstname, lastname, date1, date2 order by firstname, lastname, date1, date2 ) flag1FROM yourTable; |
|
|
bmsra79
Starting Member
24 Posts |
Posted - 2013-01-29 : 12:12:57
|
Works partiallyFlag should be 0 for all customers where the SaleID is blank. Increment should start by 1 for each record having a SaleID and Date1 (or) SaleID and Date2 |
|
|
|
|
|