Query Help Please

  • 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.

  • Seems you know what you need to do, you want to group the data, so have you had a look at the GROUP BY clause and aggregate functions? There's also the DISTINCT keyword as well, which is specifically for getting a dataset where every row has a distinct value. Have a read of the documentation and hopefully those will help you with your goal.

    If you don't achieve what you're after, reply here with your attempts. Don't post your attempts as images though; posting images of code makes it much harder to help you. Code is text and so you should post it as code too. There's a handy button near to bottom of the reply window you can use to present your code nicely to us (the one labeled SQL Code). Just highlight your code and click the button:

    If your attempt(s) don't work, explain why they didn't work too. Posting your/sample data, and the result you want may help as well (again, not as an image, formatted text is fine), so that we can make use of the data too and see what isn't working by testing.

    If you've questions about the functionality I've linked above, please do feel free to ask.

    Good luck!

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • Thanks Thom, I appreciate the feedback. I will take a look at the documentation you referenced and let you know my results.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply