SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 maintain total pax
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

peace
Constraint Violating Yak Guru

410 Posts

Posted - 04/12/2013 :  00:53:59  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
2217 Posts

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

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 04/12/2013 :  04:36:25  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000