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 468211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:39:33+00:00 2026-05-12T23:39:33+00:00

I have a table(offer) with three columns, id, product_id and price. offer —– id

  • 0

I have a table(offer) with three columns, id, product_id and price.

offer
----- 
id (integer)   
product_id (integer)
price (decimal)

I wanted to fire a SQL query which will return the number of offers between a price range.
range should be like 0-1, 1-2, 2-3 etc

price_lower   price_upper    number_of_offers
-------------------------------------------------------------
0                     1            4
1                     2            1
2                     3            0
3                     4            6
4                     5            2
... etc

I did this to get the number of offers between 0 and 1

SELECT * FROM offer WHERE price BETWEEN 0 and 1;

What should be the query to get desired result.

Any sort of help will be appreciated. Thanks in advance.

  • 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-12T23:39:34+00:00Added an answer on May 12, 2026 at 11:39 pm

    While Checking all the answers. I have managed to write the query of course with your help.
    As few of you suggested to create a new table to store offer range which i don’t want to do.

    So, here is the SQL query what i wanted:

    SELECT price as price_lower, (price + 1) as price_upper, (SELECT count(*) from offer WHERE price BETWEEN o.price and (o.price + 0.99)) from offer o GROUP BY price;
    

    Thanks to all for your great efforts. You guys rock.

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

Sidebar

Related Questions

I have table View with grouped style with three sections. Get information from dictionary
I have table with two columns (varchar from, varchar to). This table represents connections
I have a table in sql server 2005 which holds an ip range and
This is a very simple example: I have a table with two columns, id
I have a table, InnoDB, with columns id(int), name(varchar) and info(text). I need to
I have multiple MySQL tables containing varying numbers of columns. After joining three of
Does SQL Server 2008 offer any pre-defined table types for use with table-valued parameters?
I have table with around 70 000 rows. There is 6000 rows that i
I have table in which I am inserting rows for employee but next time
I have table and this table contain result column with some entries. I just

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.