Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8604485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:35:05+00:00 2026-06-12T02:35:05+00:00

I’m a student developer currently taking a SQL course. I’m currently trying to retrieve

  • 0

I’m a student developer currently taking a SQL course. I’m currently trying to retrieve the sum of several groups of rows from a table. I’m very new to SQL development and I’m not too sure what the problem is in the following scenario. I have a large table of which I want to select specific rows from and then add the balance column.

The following will not display any data in the results and I’m not too sure why. I have a hunch that the between statement can only be used once per table but maybe I’m wrong?

Select Description, SUM(Balance) AS Total_Balance
FROM Chart_Of_Accounts
WHERE (Account BETWEEN ('400401') AND ('400407')) 
AND (Account BETWEEN ('440094') AND ('440100')) 
AND (Account BETWEEN ('450094') AND ('450100'))
GROUP BY Description, Balance 

Edit 10.1.2012 As requested by (Richard aka cyberkiwi)

What I Have

Set 1
|Account        |Description         |Balance
|4004xx         |Red Wine            |$2361.23
|4004xx         |White Wine          |$3620.23
|4004xx         |Rice Wine           |$1223.23

Set 2
|Account        |Description         |Balance
|4400xx         |Red Wine            |$4361.23
|4400xx         |White Wine          |$3260.23
|4400xx         |Rice Wine           |$223.23

Set 3
|Account        |Description         |Balance
|4500xx         |Red Wine            |$1361.23
|4500xx         |White Wine          |$1620.23
|4500xx         |Rice Wine           |$1223.23

Result I’m Trying to Achieve

Total
|Description         |Total_Balance
|Red Wine            |$8083.69
|White Wine          |$8500.69
|Rice Wine           |$2669.69

thank you for reading my post! I am also open to any advice in SQL development and any feedback is greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:35:06+00:00Added an answer on June 12, 2026 at 2:35 am

    Use ORs instead of ANDs!
    What you mean to express is, give me results where it is between A and B, or it is between C and D etc.

      SELECT Description, SUM(Balance) AS Total_Balance
        FROM Chart_Of_Accounts
       WHERE (Account BETWEEN '400401' AND '400407') 
          OR (Account BETWEEN '440094' AND '440100') 
          OR (Account BETWEEN '450094' AND '450100')
    GROUP BY Description
    

    I dropped the extraneous brackets, but you could even drop the remaining ones becaues the ORs get processed after the ANDs. See: SQL Server Operator Precedence

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.