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
 SQL Server Development (2000)
 Counting Records Conditionally

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-04-20 : 08:26:50
Bruce writes "Your site says this should be used for TOUGH SQL questions. I'm not sure how tough this is, but:

If I have a table containing 6 records:

Field1
3
4
4
5
4
3

How do I get back a cursor that looks like:
Field1 Field2
3 2
4 3
5 1

Note that Field2 is the number of database records which have Field1 as the Field1 Value. That is, there are two threes, three fours, and one five in the table. How do I pull the counts of the values?

Thanks,

Bruce"
   

- Advertisement -