April 15, 2015 at 8:46 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 15, 2015 at 9:43 pm
itsgaurav (4/15/2015)
SirI 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??????
SELECT sr_no = DENSE_RANK()OVER(ORDER BY pd_name)
,pd_id
,pd_name
FROM dbo.Product
;
... and please see the article at the first link under "Helpful Links" in my signature line below for future posts, please.
--Jeff Moden
Change is inevitable... Change for the better is not.
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