Click here to Skip to main content
16,013,082 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i got some tables like this ->

table jobdetails(
JobNo int,
Techname varchar,
completed date)


table users(
username varchar,(this one and techname are same)
groupname varchar (example tech)


i have more than 25 tech users in the table .
i want to check top most tech based on completed date. in my mind only i have to select each one tech and count how many they completed today. and compare with each other and show the data back. there is any other option i can use without select 25 tech
seperatly? give me some idea if you done something like this. thanks
Posted
Updated 29-Mar-15 0:33am
v3

Try:
SQL
SELECT TOP 1 * FROM Jobdetails
ORDER BY Completed DESC
 
Share this answer
 
If you want to get all techs from users table and jobs completed by each of them, try this:
SQL
SELECT u.username, u.groupname, COUNT(j.completed)) AS CompletedJobsCount
FROM  [users] AS u LEFT JOIN jobdetails AS j ON u.username = j.Techname
WHERE j.completed = '2015-03-29'
GROUP BY u.username, u.groupname
 
Share this answer
 
Comments
tastini 29-Mar-15 6:54am    
Amazing, thanks really thanks... this is it. :)
Maciej Los 29-Mar-15 6:56am    
You're very welcome ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900