Subtotaling DB Queries

Results 1 to 2 of 2

Thread: Subtotaling DB Queries

  1. #1
    Join Date
    Dec 1969

    Default Subtotaling DB Queries

    Is there some way to subtotal the results of a query? I have a query that will return codes (ie A01, A01A, A02C) The query will list all of them but can I build a sql statement that will subtotal each code for me (ie 5-A01, 11-A01A, 20-A02C) Thanks in advance for any help.<BR><BR>Lane

  2. #2
    Join Date
    Dec 1969

    Default Easy...but...

    You can return subtotals, but then you can&#039t return all the items. You pays your money and takes your choice with SQL.<BR><BR>You could do:<BR><BR>SELECT Sum(amount) AS SubTotal, TheCode <BR>FROM table<BR>GROUP BY TheCode<BR>SORT BY TheCode<BR><BR>and that will get you *just* the SubTotal for each code. If that&#039s what you want, you&#039re home.<BR><BR>But if you wanted to *also* get the amounts for each individual record (multiple amounts per code), then you&#039ll have to do the subtotaling in your VBS code.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts