Computing.Net > Forums > Programming > SQL - very simple question but HELP

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

SQL - very simple question but HELP

Reply to Message Icon

Name: VaN
Date: July 29, 2005 at 18:37:40 Pacific
OS: Win XP Pro SP1
CPU/Ram: Athlon2800 / 1GB DDR
Comment:

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.............|...66

should display
------------------------
Store_ID | Employee_Count
------------------------
1.............|...3



Sponsored Link
Ads by Google

Response Number 1
Name: SN
Date: July 29, 2005 at 20:24:21 Pacific
Reply:

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


0

Response Number 2
Name: fleetmack
Date: August 1, 2005 at 08:06:32 Pacific
Reply:

oracle would be the same...

select store_id,
count(empolyee_id)
from store
group by store_id


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


dos appending last line o... manipulating text files



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: SQL - very simple question but HELP

simple VB question Please Help www.computing.net/answers/programming/simple-vb-question-please-help/6021.html

HELP PLZ!!! C++ .net www.computing.net/answers/programming/help-plz-c-net-/10294.html

Data Types Comsultancy www.computing.net/answers/programming/data-types-comsultancy/13020.html