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)
 Quick help with a count based on 2 columns

Author  Topic 

zeeshan13
Constraint Violating Yak Guru

347 Posts

Posted - 2006-12-11 : 15:44:06
Hi All,
I am pretty new in to SQL.

I have a table Table1 with following 2 fields.
[sales unit](nvarchar type),and IfBB (nvarchar type)

The Table1 has follwing records. (Fileds/records are sperated by comma ')
[sales unit], IfBB

Not assigned, BB
Number of items, BB
Number of items, BB
Not assigned, NO
Not assigned, NO


I want to get a count on a combination of the above 2 columns. That is in the above example I should see the following.

[sales unit], IfBB, Count

Not assigned, BB, 1
Number of items, BB, 2
Not assigned, NO, 2

Any idea?

Thanks,

Zeeshan


tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-12-11 : 15:50:17
SELECT [sales unit], IfBB, COUNT(*)
FROM Table1
GROUP BY [sales unit], IfBB

Tara Kizer
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-12-12 : 05:42:19

Also Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -