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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Problems with counting values

Author  Topic 

xdk1x
Starting Member

9 Posts

Posted - 2004-07-06 : 04:31:06
Hi!

I've got a table with some coloums like this:

T1, T2, Number, Code

There are three possibilities for the Code-row (A,B,C). Now I want to count the elements in the Number-row with the same T1 and T2 for all Codes, e.g.

T1___T2___Number____Total____A___B___C

54___43____4711______12____8____3___1

Hope anyone can help me!!!

Thank you

Daniel

nfsoft
Starting Member

36 Posts

Posted - 2004-07-06 : 04:50:47
I'm confuse but...

I asume you are taking
- T1 and T2 as Constraints
- Number as a select count(distinct Number)
- A B C as the grouping agregation

That would be:
SELECT count(distinct B.number)
FROM yourTable A
INNER JOIN yourTable B ON A.T1 = B.T1 AND A.T2 = B.T2
GROUP BY A.a, A.b, A.c

this is probably wrong but its a start.


Nuno Ferreira
Go to Top of Page
   

- Advertisement -