Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 maintain total pax

Author  Topic 

peace
Constraint Violating Yak Guru

420 Posts

Posted - 2013-04-12 : 00:53:59
i have total pax of 5.
1 pax can buy multiple items.
how can i maintain the pax to 5?

pax item
1 A
1 B
1 C
1 D
1 E

result should be:

totalPax Item ID
5 A 111
B 111
C 111
D 111
E 111

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-04-12 : 01:11:23
SELECT *, COUNT(Item) OVER(PARTITION BY Pax)
FROM @pax
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-04-12 : 04:36:25
what happened to B,C etc? why they dont have any value for totalpax?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -