April 15, 2015 at 8:45 pm
Sir
I have a five rows such AS
pd_id pd_name
11 Prod-1
22 Prod-2
33 Prod-2
44 Prod-3
55 Prod-4
When I Use Query
Select sr_no=ROW_NUMBER() OVER(ORDER BY pd_name),pd_id,pd_name
From Product
it display
sr_no pd_id pd_name
1 11 Prod-1
2. 22 Prod-2
3. 33 Prod-2
4. 44 Prod-3
5. 55 Prod-4
is it possible to display when change of product????
sr_no pd_id pd_name
1 11 Prod-1
2 22 Prod-2
2 33 Prod-2
3 44 Prod-3
4 55 Prod-4
means on prod-2 should be same serial number.
kindly suggest??????
April 16, 2015 at 7:00 am
Duplicate post. direct replies here. http://www.sqlservercentral.com/Forums/Topic1677466-202-1.aspx
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy