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)
 Query help with a count statement

Author  Topic 

vravo
Starting Member

13 Posts

Posted - 2008-08-15 : 12:41:53
I have two tables and the first table has Drop down values and the second tables has a text field and the drop down selection is unfortunatly is just inserted into the middle of text field... there is at least 30 selections in the first table that belong to the drop down list and I want to count the number of times the drop down categories are used in the textfield in the other table... there is no link between the 2 tables... I didn't create this but need to generate a report from it.

Table DDV
---------
DDV_ID DDV_Index DDV_Value
10(subject) 1 Intial Meeting
10 2 Follow up Meeting
10 3 Product Review

Table Comments
---------------
Company_ID DateTime UserId Comments
1234567890 2008-08-01... smithJ Stop by for a vist....Subject:Follow up Meeting
0987654321 2008-08-02... JonesR Called customer....Subject:Product Review


what I'm looking For!!!
Result query
-----------------------
Subject Count
Intial Meeting 19
Follow up Meeting 12
Product Review 26


I can do a like statement and pull a count individually or hard code then but that's not efficent!!

Thanks in advance for any help....

Thanks

Vin

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-15 : 12:51:52
may be this?
SELECT d.DDV_Value,COUNT(c.Company_ID)
FROM DDV d
INNER JOIN Comments c
ON c.Comments LIKE '%'+ d.DDV_Value + '%'
GROUP BY d.DDV_Value
Go to Top of Page

vravo
Starting Member

13 Posts

Posted - 2008-08-15 : 14:22:51
Perfect!!!!

Thank you!!!!

Thanks

Vin
Go to Top of Page
   

- Advertisement -