Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I'm new to it. I've struggeld on this for hours, I don't understand what's wrong. You don't need to explain anything (though it would help), just write a query.Table Stores( Store_ID, Employee_ID );
The query must list Store_ID with the largest number of employees, and the number of employees in that store.
E.g. query on this
Stores
------------------------
Store_ID | Employee_ID
------------------------
1.............|...11
1.............|...22
1.............|...33
2.............|...44
2.............|...55
3.............|...66should display
------------------------
Store_ID | Employee_Count
------------------------
1.............|...3

You didn't specify what kind of database we're using here. You also didn't specify what to do if there's a tie in how many employees a store has.
Anyhow, here's a mySQL 4.0 version of it:
SELECT Store_ID, count(Employee_ID) as Employee_Count FROM Stores GROUP BY Employee_ID ORDER BY Employee_Count DESC LIMIT 1;Good luck,
-SN

![]() |
dos appending last line o...
|
manipulating text files
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |