Group By Clause...

Results 1 to 2 of 2

Thread: Group By Clause...

  1. #1
    Join Date
    Dec 1969

    Default Group By Clause...

    Need assistance in causing the GROUP BY clause to add the values in a variable to create a total.<BR><BR>The SQL is as so:<BR><BR>SELECT RR.REGION_NUMBER_RECRUITED <BR>FROM ...<BR>WHERE ...<BR>GROUP BY RR.REGION_NUMBER_RECRUITED<BR><BR>This GROUP BY as provided above does provide the correct output, but the output includes several records, but the records have not been added together. How do I total them as well in one SQL statement. I tried to use the SUM() function, but to no avail. Any advice?<BR>

  2. #2
    Join Date
    Dec 1969

    Default Should be asking this in Database forum..

    ...since it&#039;s not advanced, really. Just a basic understanding of how SQL works is needed.<BR><BR>You say "I tried to use the SUM() function" but you don&#039;t say *how* you tried or what message(s) [if any] you got.<BR><BR>SUM() is definitely the ticket, but it must be used correctly.<BR><BR>Ummm...I just re-read what you wrote: <BR><BR>"...the records have not been added together. How do I total them *AS WELL* [emphasis mine] in one SQL statement..."<BR><BR>You don&#039;t. You can do one or the other, but not both. Fundamental weakness (and strength, for performance reasons) of SQL.<BR><BR>Either make two separate queries or do the summing with a tiny bit of VBS code after you make the GROUP BY query.<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