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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:28:50+00:00 2026-05-21T09:28:50+00:00

Given the 2 tables below, show only the activity times when the product was

  • 0

Given the 2 tables below, show only the activity times when the product was not offline. Keep in mind that this is a small sample of data. There will be multiple products in the activity table and multiple timestamps in the offline table.

The goal is to output when the product was online. so given the data below, I need a query that will return : rows 3,6,7 – these are the timestamps when the product was online.

mysql> select * from activity;
+------------+---------------------+
| product_id | activity_date       |
+------------+---------------------+
|          1 | 2011-04-13 12:00:00 |
|          1 | 2011-04-13 01:00:00 |
|          1 | 2011-04-13 02:00:00 |
|          1 | 2011-04-13 03:00:00 |
|          1 | 2011-04-13 04:00:00 |
|          1 | 2011-04-13 05:00:00 |
|          1 | 2011-04-13 06:00:00 |
+------------+---------------------+
7 rows in set (0.01 sec)

mysql> select * from offline
+------------+---------------------+---------------------+
| product_id | offline_start       | offline_end         |
+------------+---------------------+---------------------+
|          1 | 2011-04-13 12:00:00 | 2011-04-13 01:00:00 |
|          1 | 2011-04-13 03:00:00 | 2011-04-13 04:00:00 |
+------------+---------------------+---------------------+
2 rows in set (0.01 sec)
  • 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-21T09:28:51+00:00Added an answer on May 21, 2026 at 9:28 am
    create table activity
    (
        product_id int,
        activity_date datetime
    );
    
    create table [offline]
    (
        product_id int,
        offline_start datetime,
        offline_end datetime
    );
    
    insert into activity(product_id, activity_date) 
      values (1, '2011-04-13 12:00:00 AM')
            ,(1, '2011-04-13 01:00:00 AM')
            ,(1, '2011-04-13 02:00:00 AM')
            ,(1, '2011-04-13 03:00:00 AM')
            ,(1, '2011-04-13 04:00:00 AM')
            ,(1, '2011-04-13 05:00:00 AM')
            ,(1, '2011-04-13 06:00:00 AM');
    
    insert into [offline](product_id, offline_start, offline_end) 
      values (1, '2011-04-13 12:00:00 AM', '2011-04-13 01:00:00 AM')
            ,(1, '2011-04-13 03:00:00 AM', '2011-04-13 04:00:00 AM');        
    
    select  a.*
    from    activity a
            left join offline o
                on a.product_id = o.product_id
                and a.activity_date between o.offline_start and o.offline_end
    where   o.product_id IS NULL
    

    Don’t have a mysql server setup at home to test it but if the AM doesnt work, then 12 AM is 00:00:00 so the first entry on the activity table should be

    1, '2011-04-13 00:00:00'
    

    and the first entry for the offline table should be

    1, '2011-04-13 00:00:00', '2011-04-13 01:00:00'
    

    tested this on my sql server and here is the output:

    product_id  activity_date
    1   2011-04-13 02:00:00.000
    1   2011-04-13 05:00:00.000
    1   2011-04-13 06:00:00.000
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the use of the below given tables in Joomla Database? jos_core_acl_aro jos_core_acl_aro_groups
Given the Below Tables. How do I get the Distinct name given the other
I have 10 tables in my database(MySQL). two of them is given below tbl_state
I was once given this task to do in an RDBMS: Given tables customer,
I have a a databasehelper and an activity with codes given below. The problem
Given the example queries below (Simplified examples only) DECLARE @DT int; SET @DT=20110717; --
Given the one-table design given below how would the following best be queried The
Given the following html table and script shown below I am having a problem
Why does the MySQL query below give error 1066 (Not unique table/alias: 'customer') ?
Given two tables, one for workers and one for tasks completed by workers, CREATE

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.