Query Help please

%3CLINGO-SUB%20id%3D%22lingo-sub-382879%22%20slang%3D%22en-US%22%3EQuery%20Help%20please%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-382879%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20still%20quite%20a%20beginner%20at%20this%20SQL%20querying%2C%20so%20I%20appreciate%20any%20help%20on%20this.%20I%20have%20pulled%20the%20data%20I%20need%20using%20the%20below%20query.%20Now%20I%20need%20to%20group%20the%20data%20by%20cmp_name%20and%20sum%20the%20ivh_totalcharge%20for%20each%20cmp_name.%20Also%2C%20need%20to%20make%20sure%20I%20pull%20distinct%20records%20from%20the%20field%20ord_hdrnumber%20from%20the%20invoiceheader%20table.%20Thank%20you%20for%20any%20help%2C%20I%20appreciate%20it.%3C%2FP%3E%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fi.gyazo.com%2F7b4af489e3e5213d18b435c57fea9643.png%22%20border%3D%220%22%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-382879%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Egroup%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESQL%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Esum%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-389375%22%20slang%3D%22en-US%22%3ERe%3A%20Query%20Help%20please%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-389375%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F238560%22%20target%3D%22_blank%22%3E%40Tim%20Hunter%3C%2FA%3E%26nbsp%3Bwrite%26nbsp%3B%3CSPAN%3Eivh_totalcharge%26nbsp%3B%20with%20SUM(ivh_totalcharge%26nbsp%3B)%20after%20WHERE%20clause%2C%20write%20GROUP%20BY%20for%20other%20columns%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Regular Contributor

I am still quite a beginner at this SQL querying, so I appreciate any help on this. I have pulled the data I need using the below query. Now I need to group the data by cmp_name and sum the ivh_totalcharge for each cmp_name. Also, need to make sure I pull distinct records from the field ord_hdrnumber from the invoiceheader table. Thank you for any help, I appreciate it.

1 Reply
Highlighted

@Tim Hunter write ivh_totalcharge  with SUM(ivh_totalcharge ) after WHERE clause, write GROUP BY for other columns