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