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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:49:30+00:00 2026-06-12T22:49:30+00:00

I have an SQL query that currently displays all the people in table HOTEL

  • 0

I have an SQL query that currently displays all the people in table HOTEL that booked a hotel between $260 and $350. I’m using ORACLE

SELECT guest.guest_name "GUEST NAME", 
       Count(guest.guest_no), 
       guest.guest_no   "GUEST           NUMBER", 
       room.r_price     "ROOM PRICE" 
FROM   room, 
       guest, 
       booking 
WHERE  r_price >= 260 
       AND r_price <= 350 
       AND guest.guest_no = booking.guest_no 
GROUP  BY guest.guest_no, 
       guest.guest_name, 
       room.room_price 
ORDER  BY guest.guest_name; 

I thought that I could group by just GUEST.GUEST_NAME (so it puts all of the count under the one name rather than doubling up on the guest names).

EDIT: The current results of the query look like this:

    GUEST NAME    COUNT   GUEST_NO R_PRICE
    Jenny Freeman   2   G003    260
    Jenny Freeman   2   G003    295
    Jenny Freeman   2   G003    310
    Martin Ferguson 3   G006    260
    Martin Ferguson 3   G006    295
    Martin Ferguson 3   G006    310
    Paul Happy  3   G002    260
    Paul Happy  3   G002    295
    Paul Happy  3   G002    310
    Steve Kirkwood  3   G005    260
    Steve Kirkwood  3   G005    295
    Steve Kirkwood  3   G005    310
    Tina Duncan 2   G001    260
    Tina Duncan 2   G001    295
    Tina Duncan 2   G001    310
    Vanessa Horton  1   G007    260
    Vanessa Horton  1   G007    295
    Vanessa Horton  1   G007    310

But I’m expecting something like this:

    GUEST NAME    COUNT   GUEST_NO R_PRICE
    Jenny Freeman   6   G003    260
    Martin Ferguson 9   G006    310
    Paul Happy  9   G002    310
    Steve Kirkwood  9   G005    260
    Tina Duncan 6   G001    310
    Vanessa Horton  3   G007    260
  • 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-12T22:49:32+00:00Added an answer on June 12, 2026 at 10:49 pm

    Well, I think you just have to change in group by statement rest looks OK to me. Just don’t include Room price in Group By statement, i think that is creating problem for you if i am getting your question right…

     GROUP BY GUEST.GUEST_NO,
              GUEST.GUEST_NAME
    

    and

     MAX(R_PRICE) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have the following SQL query that lists all the names of all
I currently have a SQL query that returns a number of fields. I need
I have an SQL query that returns all companies records ignore the ones with
I currently have a SQL query that is displaying several columns of data. In
I have this SQL Query that pulls data from 3 tables. I am unable
I have a SQL query that returns a Datatable: var routesTable = _dbhelper.Select(SELECT [RouteId],[UserId],[SourceName],[CreationTime]
I have a SQL query that I'm trying to debug. It works fine for
I have a SQL query that I'm trying to write, but I'm not quite
Suppose I have a SQL Query that isn't really nice. The SQL Query has
I need to be able to have an SQL query that searches my database

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.