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

  • SEARCH
  • Home
  • 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 4171284
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T00:25:42+00:00 2026-05-21T00:25:42+00:00

My table structure is as follows **ID** **datefrom** **dateto** **amount** 1 2011-03-01 2011-03-04 3500

  • 0

My table structure is as follows

**ID**     **datefrom**         **dateto**    **amount**
  1         2011-03-01          2011-03-04      3500
  2         2011-03-05          2011-03-10      2500

I need to search in both rows and get the sum of the amount and number of rows

I need to retrieve all the rows which are between the user input 2 date values, from date and to date. I write a query as follows:

SELECT SUM(amount) as amount, COUNT(amount) as numcount 
FROM rate 
WHERE "2011-03-03" BETWEEN datefrom AND dateto 
AND "2011-03-06" BETWEEN datefrom AND dateto

But its not working as I expected, I need to search all the datefrom and dateto rows to find the given dates and get the number of the rows and the sum of the amount, pls somebody help me with the correct query

  • 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-05-21T00:25:42+00:00Added an answer on May 21, 2026 at 12:25 am

    We aren’t sure yet what results you are expecting, but should you be using OR instead of AND for the two date ranges?

    WHERE "2011-03-03" BETWEEN datefrom AND dateto 
    OR "2011-03-06" BETWEEN datefrom AND dateto
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following table structure ZoneID int ZoneName varchar(50) I need to get
I have a table structure as follows. Now I need to sort these nested
hopefully somebody can help The table structure is as follows: tblCompany: compID compName tblOffice:
I have a table and the structure of it is as follows: VoteId QuestionId
My table structure is as follows: mid | tid | data | 1 |
My table structure is as follows: Person 1-M PesonAddress Person 1-M PesonPhone Person 1-M
I have a table with a current structure as follows: Currently this is populated
The table structure is as follows: NOTE : The names used are for illustrative
I have got a table structure which is as follows: `CREATE TABLE "pages" (
I have table structure as follows id productid ip hittime --------------------------------------------------------------------------- 1 5 1.1.1.1

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.