Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Group By Question

Status
Not open for further replies.

mark1110

Programmer
Apr 20, 2005
85
0
0
US
Will this Group By statement work with ANSI SQL:

SELECT max(last_updated_dt) as max_dt, field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15
INTO #temp_table
FROM myTable
GROUP BY field1, field2, field3
HAVING last_updated_dt = max(last_updated_dt)

Or do I need to put all the fields except for the date field in the group by?

Thanks,
 
The general GROUP BY rule is:
If a GROUP BY clause is specified, each column reference in the SELECT list must either identify a grouping column or be the argument of a set function.

I.e. list all columns except last_updated_dt in the GROUP BY clause.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top