|
-
Feb 10th, 2017, 02:24 PM
#1
Thread Starter
Frenzied Member
How do I get multiple columns with MAX SQL function?
I went to W3Schools and learned the MAX function. They have a "Try it" feature and SELECT ProductID, MAX(Price) FROM Products works. In SSMS SELECT Max(Time) FROM Accounts works but SELECT ID, Max(Time) FROM Accounts results in the error "Column 'Accounts.ID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause." Is this a difference between SQL and TSQL or am I doing something wrong? How do I add columns?
I know I can do a "Select Top 1" and order by date descending but I want to learn how to get the MAX function to work.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|