Skip to main content
gamedev.net
🔒 Locked

[web] SQL sub query problem

Started by johnnyBravo Oct 11, 2006 at 9:42 PM 0 replies 1k views
Original Post
johnnyBravo
johnnyBravo
I've got my table staffworksoncampaign (cut down version) -title that has data like title ----- 'A' 'A' 'A' 'A' 'B' 'B' 'D' 'D' 'D' 'D' 'D' And I want to return the title and count where the count is > 3 eg: title count ----- ----- 'A' 4 'D' 5 Heres what I've got so far which just returns the distinct title and its count: select title, count(*) from staffworksoncampaign group by title; I thought I could do a subquery something like: where (select count(*) from staffworksoncampaign group by title) > 3 though my problem is matching the 'title' from the subquery and outer query . thx
sosa222
sosa222

Use this.

select title, count(*)
from staffworksoncampaign
group by title
having count(*) > 3

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.