•
•
•
•
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:
Rep Power: 0
Solved Threads: 0
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
and this gives
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
which gives
But that doesn't help much as i have nothing about which employeeid it corresponds to! Just the highest value!
Thank-you
DJ CLipz
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
sql Syntax (Toggle Plain Text)
SELECT EMPLOYEEID, count(*) FROM ABSENCEHISTORY GROUP BY EMPLOYEEID HAVING count(*)>= ALL(SELECT count(*) FROM ABSENCEHISTORY GROUP BY EMPLOYEEID);
and this gives
EMPLOYEEID COUNT(*)
---------- ----------
2 4Now 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
sql Syntax (Toggle Plain Text)
SELECT max(count(*)) FROM ABSENCEHISTORY GROUP BY EMPLOYEEID;
which gives
MAX(COUNT(*))
-------------
4But 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
•
•
•
•
•
•
•
•
DaniWeb Oracle Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- SQL String question (ASP)
- Questions for Web Gurus! (*??*) (ASP.NET)
Other Threads in the Oracle Forum
- Previous Thread: Dates between the two given dates
- Next Thread: Auto increment



Threaded Mode