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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:41:54+00:00 2026-06-11T18:41:54+00:00

Hello this is are 2 tables on my db : I’m trying to get

  • 0

Hello this is are 2 tables on my db :
enter image description here

I’m trying to get the hotels available for a interval of dates.
In the Rooms table are defined the types of rooms : eg Signe:max_guests=1, Triple : max_guests=3
So for 10 people booking i need something like:

SELECT  SUM(rooms.max_guests * av.RoomAvailable) AS maxPeople 
FROM av AS av INNER JOIN rooms 
ON av.room = rooms.ID AND av.DateofDays BETWEEN '09/28/2012' AND '10/03/2012' 
GROUP BY av.userid
HAVING Count(*) >= 6

but this doesn’t really fit my requirements ..it return me total max_people available/ userID i just need to check if every day for each userID(hotel) there’s >= 10 (max_people) available

Thank yo for your help

Update: if i use this query :

SELECT  av.userid, av.DateofDays, SUM(rooms.max_guests * 

av.RoomAvailable) AS maxPeople 
FROM av AS av INNER JOIN rooms 
ON av.room = rooms.ID AND av.DateofDays BETWEEN '09/28/2012' 

AND '10/03/2012' 
GROUP BY av.userid, av.DateofDays
ORDER BY av.userid, av.DateofDays

i get this:
enter image description here

  • 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-11T18:41:55+00:00Added an answer on June 11, 2026 at 6:41 pm

    You have to manually put in the number of days in the count.

    WITH cte AS (
    SELECT  av.userid, av.DateofDays, SUM(rooms.max_guests * av.RoomAvailable) AS maxPeople 
    FROM av AS av INNER JOIN rooms 
    ON av.room = rooms.ID AND av.DateofDays BETWEEN '09/28/2012' AND '10/03/2012' 
    GROUP BY av.userid, av.DateofDays
    HAVING SUM(rooms.max_guests * av.RoomAvailable) >= 10 
    )
    select cte.userid 
    from cte 
    group by av.userid 
    having COUNT(*) = 6
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have like this 2 tables class User public int UserId{get;set;} { ....
hello having 2 tables like this TABLE products_ids id_product_unique 1 2 TABLE products_list id_product
Take this table WORDS WORD Hello Aardvark Potato Dog Cat And this list: ('Hello',
hello all this seems to be my problem I have a table in mysql
I have UserComments table like this : 1 | Frank | hello world 2
I have a table like this: someid somestring 1 Hello 1 World 1 Blah
This <table> <tr> <td>Hello</td> <td>World</td> </tr> </table> Can be done with this: <div> <div
Hello this is code snippet which i get from Jquery Ajax based search I
I get a string which contains a sentence in two lines : 'hello this
Hello I have 2 tables that look like this, What I wanting to is

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.