Link to home
Start Free TrialLog in
Avatar of dyarosh
dyarosh

asked on

SQL help on a complicate query

I have a table that contains vehicle information for owners.  The table has an ownerid to map vehicles to owners.  What I need is a query that will tell me how many owners have more than 3 vehicles.  I don't need the details, just the count.  So for example:

Vehicle Table
VID       OID
1           100
2           100
3           200
4           300
5           300
6           300
7           300
8           400
9           400
10         400
11         500
12         500
13         500
14         500
15         500
16         500

The SQL would return 2 - OID 300 and OID 500 have more than 3 vehicles.  Can anyone help me with this?  We are using MS SQL Server 2005.
ASKER CERTIFIED SOLUTION
Avatar of ralmada
ralmada
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dyarosh
dyarosh

ASKER

Thank you.  I knew I had to use a Group BY but didn't know where.