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.
Author |
Topic |
jenskp
Starting Member
5 Posts |
Posted - 2010-11-03 : 00:45:56
|
Hello, I have a table structure in this formatUsername Count Pid A1 4 0C1 2 A1C2 0 A1C3 0 C1C4 0 C1 When A1 is inserted, the count will be 0 and Pid will be 0.But, when C1 is inserted, the Count of C1 will be 0 and A1 will be 1 and Pid will be A1.When C2 is inserted, the Count of C2 will be 0 and A1 will be 2 and Pid will be A1But, when C3 is inserted, the count of C1 will be 1 and C2, C3 and C4 will be 0 and A1 will be 3.And the Pid’s of C3 and C4 will be C1 and so on..So, how will I find out the Count and Pid’s C1.C2,…..CN?- Thanks Jenskp |
|
KlausEngel
Yak Posting Veteran
85 Posts |
Posted - 2010-11-05 : 21:41:21
|
Not sure I understand what you need but isn't it as simple as:SELECT username, Pid, SUM(Count) as YourCountFROM TableNameGROUP BY username, Pid |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|
|