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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:57:43+00:00 2026-05-31T13:57:43+00:00

I am writing a query for my database and basically I want to query

  • 0

I am writing a query for my database and basically I want to query a database for events happening in each room. Meaning that i want to find the earliest event happening in room 1 and the earliest event happening in room 2.

Below I have the code for performing this query for 1 room. This code only returns the earliest event in room 2. How can I perform a query where I find the earliest event for room 1 and the earliest event for room 2 and return it in a single query?

This would be performing a query on each element of an array but in a single query. Is this possible or would I have to write a query for each room?

select   name,
         eventtime,
         MIN(eventtime - currenttime) as time_from_test
from     the_table
where    the_table.room = Room1
group by the_table.room
order by time_from_test
limit 1

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-31T13:57:45+00:00Added an answer on May 31, 2026 at 1:57 pm
    select   the_table.room,MIN(eventtime) as event_start_time_of_day
    from     the_table
    group by the_table.room;
    

    For eg. if you have 5 rooms and each room has five event times then this query will retrieve the minimum event time and return it back to you by grouping all events at room level.

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

Sidebar

Related Questions

I'm writing a query that inserts customer data into a MSSQL database. Very basic.
I'm writing a query for an application that needs to list all the products
How would one go about writing a query that selects items 2000-2010 out of
I'm writing a query that has to count the number of students enrolled in
I came across writing the query in differnt ways like shown below Type-I SELECT
I am writing a server which provide a service by query MySQL database. Everything
I'm writing a query that looks like this: var TheOutput = (from x in
I am writing a query in Mysql database, in which Query 1 returns count(
I'm making a plugin that does a custom query on the WordPress database, and
Basically I am writing a report script where it pulls data from a 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.