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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:14:41+00:00 2026-06-12T16:14:41+00:00

Please help whith query. Have a table: id | u_id | start_date | end_date

  • 0

Please help whith query. Have a table:

id | u_id | start_date |  end_date  |
-------------------------------------
01 |   7  | 2012-09-05 | 2012-09-23 |
02 |   4  | 2012-09-10 | 2012-09-15 |
03 |   4  | 2012-09-27 | 2012-10-05 |
04 |   5  | 2012-10-01 | 2012-10-09 |
05 |   4  | 2012-10-10 | 2012-10-15 |
06 |   7  | 2012-10-23 | 2012-11-05 |
07 |   5  | 2012-11-05 | 2012-11-12 |
08 |   4  | 2012-11-08 | 2012-11-10 |

I want to select all records where month=10 and max “start_date” from prev month and min “end_date” from next month.
Needed as a result

id | u_id | start_date |  end_date  |
-------------------------------------
03 |   4  | 2012-09-27 | 2012-10-05 |
04 |   5  | 2012-10-01 | 2012-10-09 |
05 |   4  | 2012-10-10 | 2012-10-15 |
06 |   7  | 2012-10-23 | 2012-11-05 |

I don’t understand what i do wrong with this query

SELECT start_date, end_date
FROM _xata_owner 
INNER JOIN (
   SELECT max(start_date) AS date FROM _xata_owner
   GROUP BY DATE_FORMAT(start_date, "%m")
   ) b ON month(b.date)=09
WHERE month(start_date)=10
ORDER BY start_date

Thanks!

  • 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-12T16:14:42+00:00Added an answer on June 12, 2026 at 4:14 pm

    So you want:

    • Get records where the month in start_date is 10. For that:

      SELECT id, u_id, start_date, end_date
      FROM _xata_owner
      WHERE month(start_date)=10

    • Get the max “end_date” where the “start_date” is in the previous month:

      SELECT id, u_id, start_date, end_date
      FROM _xata_owner
      WHERE month(start_date) = 09 AND end_date =
      (SELECT MAX(end_date) FROM _xata_owner WHERE month(start_date) = 09)

    • Get the min “end_date” where the “end_date” is in the next month:

      SELECT id, u_id, start_date, end_date
      FROM _xata_owner
      WHERE month(end_date) = 11 AND end_date =
      (SELECT MIN(end_date) FROM _xata_owner WHERE month(end_date) = 11)

    Put them all together:

    (SELECT id, u_id, start_date, end_date
    FROM _xata_owner 
    WHERE month(start_date)=10)
    UNION
    (SELECT id, u_id, start_date, end_date
    FROM _xata_owner
    WHERE month(start_date) = 09 AND end_date =
            (SELECT MAX(end_date) FROM _xata_owner WHERE month(start_date) = 09))
    UNION
    (SELECT id, u_id, start_date, end_date
    FROM _xata_owner
    WHERE month(end_date) = 11 AND end_date =
            (SELECT MIN(end_date) FROM _xata_owner WHERE month(end_date) = 11))
    

    This sounds like what you want anyway. Your question is a little confusing.

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

Sidebar

Related Questions

Please help me with a query. Assume that we have a table with columns:
Please help with SQL Query to solve following issue. I have a table input
I need some help with a LINQ query in VB.Net, please. I have this
Hi i need help with a query I have a table Where Jobs and
I have a query which take data from 5 huge table, could you please
I need some help with my query. I have 2 tables: all: art|serie sootv:
please help with this mysql query in rails 3: In my controller i have:
Need a query help. I have a table where data is represented like this
Please help me with this: I have a table like: id_feature id_product id_feature_value 1
I have a query in access like below select field1, column_date, sum(qty) from table

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.