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)
 Items to be Counted in IN

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-04-24 : 23:55:38
Shahzad writes "Hello

I have another problem in TSQL. If I use the SQL Statement

Select DocumentID
From tblDocument
Where DocumentID IN (25,25,1,3,4,4,25)

It obviously gives result of DocumentID's which are present in IN. But I want to be more precise and display the DocumentID's with respect to frequencies of appearence. e.g 25 appears three time in IN, so if it is present in DB as well. It should be the first DocumentID to be displayed and with Count as well. i.e it 3. Then 4 with count of 2. I desperately needs to solve this issue. One solution to solve it programmatically not seems to be very efficient.

Thankyou very much in advance for considering my problem. Looking forward to hear from you."
   

- Advertisement -