MySQL Find project IDs for all project start times smaller than previous project end times

Source: Internet
Author: User

This is a previously encountered SQL interview problem, for reference learning:

Find project IDs where all project start times are smaller than previous project end times

Mysql> Select *  fromT2;+----+---------------------+---------------------+|Id|Start| End                 |+----+---------------------+---------------------+|  1 |  -- on- on xx:xx:xx |  -- on- in xx:xx:xx ||  2 |  -- on- on xx:xx:xx |  -- on- A xx:xx:xx ||  3 |  -- on-Geneva xx:xx:xx |  -- on- - xx:xx:xx ||  4 |  -- Geneva-Geneva xx:xx:xx |  --Geneva- - xx:xx:xx ||  5 |  -- on-Geneva xx:xx:xx |  -- on- the xx:xx:xx ||  6 |  -- on- - xx:xx:xx |  -- Geneva- the xx:xx:xx |+----+---------------------+---------------------+

As shown above, data columns with ID 2,3,5,6 will need to be identified by manual observation.

The SQL statements are as follows:

Mysql> Select distinct(a.id) fromT2 A,t2 BwhereA.start<B.End  anda.ID>b.id;+----+|Id|+----+|  2 ||  3 ||  5 ||  6 |+----+4Rowsinch Set(0.00Sec

MySQL Find project IDs for all project start times smaller than previous project end times

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.