Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Two Seperate SQL's. I want just one code

Author  Topic 

mrdatabase
Starting Member

12 Posts

Posted - 2012-04-29 : 06:22:30
I have two seperate SQL's here and i just want one SQL code

They are

SELECT Forename, Surname, Sum(Likes) AS Total_Amount_Of_Likes
FROM Instructors, Exercise_Class_Type, Exercise_Class_Staff, Exercise_Class_Booking, Feedback
WHERE Exercise_Class_Type.Exercise_Class_ID = Exercise_Class_Staff.Exercise_Class_ID
AND Exercise_Class_Type.Exercise_Class_ID = Exercise_Class_Booking.Exercise_Class_ID
AND Exercise_Class_Booking.Exercise_Booking_ID = Feedback.Exercise_Booking_ID
AND Instructors.Instructor_ID = Exercise_Class_Staff.Instructor_ID
AND Start_Date_Time >= Date() - 30
GROUP BY Forename, Surname;



SELECT Forename, Surname, Total_Amount_Of_Likes
FROM Report_F
WHERE Total_Amount_Of_Likes = (SELECT MAX(Total_Amount_Of_Likes)
FROM Report_F);

The second SQL basically finds the max amount of likes an instructor has, is it possible to have this all in a single code via a sub query?

I am writing it in Access

Thanks

mrdatabase
Starting Member

12 Posts

Posted - 2012-04-29 : 07:32:35
solved it!
Go to Top of Page
   

- Advertisement -