Finding first and last customer movement SQL Server - tips? -
i needed help doing task in clever way. want pick out first motion on client number , sales day , same thing lastly movement.
is there someway of doing this?
these column names:
cust_no type of sale sales day activation day campaign name seller namei thinking of first taking out first motion help of
row_number() on (partition cust_no order sales day asc)
separate these results in excel file
and lastly movement:
row_number() on (partition cust_no order sales day desc)
separate them in excel file.
is there way of attaching excel file both first motion , lastly motion without doing in parts?
you can select both rows using subquery
select * ( select *, row_number() on (partition cust_no order sales day asc) seq1, row_number() on (partition cust_no order sales day desc) seq2, ) t t.seq1 =1 or t.seq2 =1
sql sql-server
No comments:
Post a Comment