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.
| Author |
Topic |
|
netsports
Starting Member
11 Posts |
Posted - 2005-09-01 : 16:10:31
|
| I need to build a select statement with fields/columnnames that do not need an aggregate function (SUM, MAX etc), but since i do have a field that gets a SUM function and goes into the GROUP BY clause, i get an error on my one field: "this field needs to be in an Aggregate function to be included in the Group By clause."I went ahead and included the field in the group by , and I did not get an error. Is this still legit in SQL ad hoc queries? |
|
|
nosepicker
Constraint Violating Yak Guru
366 Posts |
Posted - 2005-09-01 : 17:01:48
|
| From what you describe, it sounds legit, but it also depends on what you actually want. What is your select statement? |
 |
|
|
netsports
Starting Member
11 Posts |
Posted - 2005-09-01 : 18:31:45
|
quote: Originally posted by nosepicker From what you describe, it sounds legit, but it also depends on what you actually want. What is your select statement?
I am seeing the data I want from this, but i still have more data criteria to test, and i have to alter the select statement nevertheless anyways. thanks for response. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-09-02 : 01:51:15
|
| Each field you include in the Select statement that does Aggregate need to be included in Group by ClauseMadhivananFailing to plan is Planning to fail |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-09-02 : 01:53:42
|
| If you need additional columns from the rows that satisfy the aggregate, then you can do this with a derived table. Show us your SELECT statement, the one that doesn't work, and we'll show you how to do it with the use of a derived table.Tara |
 |
|
|
|
|
|
|
|