![]() |
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 :D |
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. |
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 ? |
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. |
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. |
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. |
All times are GMT -5. The time now is 01:29 PM. |
Powered by vBulletin Version 3.6.0
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.