SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Two Seperate SQL's. I want just one code
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mrdatabase
Starting Member

United Kingdom
12 Posts

Posted - 04/29/2012 :  06:22:30  Show Profile  Reply with Quote
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

United Kingdom
12 Posts

Posted - 04/29/2012 :  07:32:35  Show Profile  Reply with Quote
solved it!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000