User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Oracle section within the Web Development category of DaniWeb, a massive community of 402,689 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,450 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Oracle advertiser: Programming Forums
Views: 2362 | Replies: 5
Join Date: Apr 2008
Posts: 3
Reputation: djclipz is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
djclipz djclipz is offline Offline
Newbie Poster

SQL Query question over multiple tables

  #1  
Apr 17th, 2008
Hey all,

Ok first my problem. I have a database that has an employee table and then also an absent table(for when they are off sick).

The problem i have is using sql to find the employee that is off the most! So for my sql on the absent table i do something like this

  1. SELECT EMPLOYEEID, count(*) FROM ABSENCEHISTORY GROUP BY EMPLOYEEID HAVING count(*)>= ALL(SELECT count(*) FROM ABSENCEHISTORY GROUP BY EMPLOYEEID);

and this gives

EMPLOYEEID   COUNT(*)
----------         ----------
         2           4

Now this is all good as i now know that the employee with id 2 has had the most absences. However is it possible in 1 query to use the EMPLOYEEID i have been given there to find out the attributes of the employee that are stored in the EMPLOYEE table. I have been trying JOINS, UNIONS but no success as far. Does anyone know if it is actually possible to do this in 1 query?

I have also tried this

  1. SELECT max(count(*)) FROM ABSENCEHISTORY GROUP BY EMPLOYEEID;

which gives

MAX(COUNT(*))
-------------
            4

But that doesn't help much as i have nothing about which employeeid it corresponds to! Just the highest value!

Thank-you
DJ CLipz
Last edited by peter_budo : Apr 17th, 2008 at 7:23 pm. Reason: Keep It Organized - please use [code] tags
AddThis Social Bookmark Button
Reply With Quote  

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Oracle Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Oracle Forum

All times are GMT -4. The time now is 5:13 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC