10-09-2008, 05:09 PM | #1 | |||||
Awaiting Further Instructions...
Join Date: Nov 2001
Location: Macungie, PA
|
yet more tsql fun
here is the lovely query i've built so far
Quote:
This show me all the data I want. However, I want to sum all the same li.nitemid together. I know I have to utilize group by, but I become retarded when it comes to group by. i'm getting closer, I figured out I couldn't keep in the norderid or the date since that wouldn't be able to group by that. I know have: Quote:
I want to do this: Quote:
but I get: error: column i.sItemNumber is invalid because it is not contained in either an aggregate function or group by clause. what's screwing me up is that I put everything into separate tables but now they are a pain to query
__________________
|
|||||
10-09-2008, 05:12 PM | #2 | |
Awaiting Further Instructions...
Join Date: Nov 2001
Location: Macungie, PA
|
oops, I think I answered my own by removing the offending selects
Quote:
Anyone have an easy way to think about sum and grouping... always fricks me up.
__________________
|
|
10-09-2008, 05:13 PM | #3 |
Awaiting Further Instructions...
Join Date: Nov 2001
Location: Macungie, PA
|
One thing, however, is I want to bring the item description over (so they can see what the item is - item number lone doesn't tell much) and I can't becaus of the group by.
Any way to keep in the i.sItemDesc ?
__________________
|
10-09-2008, 05:15 PM | #4 | |
Awaiting Further Instructions...
Join Date: Nov 2001
Location: Macungie, PA
|
fucking moron... I just added it to the end
Quote:
and it seems to be there now. I just needed to make a sql-ass out of myself to the world so I could figure it out.
__________________
|
|
10-09-2008, 05:42 PM | #5 | |
High School JV
Join Date: Nov 2006
|
Quote:
The simple rule for summing/grouping is that any column which is returned in the recordset which is not being summed, has to in the group by. |
|
10-10-2008, 09:50 AM | #6 | |
Awaiting Further Instructions...
Join Date: Nov 2001
Location: Macungie, PA
|
Quote:
Aaaaaaaah! Thanks. When I added i.sItemDesc, enterprise manager auto-added it to the group by and I didn't see that. Makes total sense and I should probably take a few classes on SQL. Problem is I only use it intensely a few times a year.
__________________
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
|
|