两个日期之间的每个联合行开始日期列和结束日期列

时间:2018-03-19 08:33:40

标签: mysql sql

我有一张桌子,

Sr no   name    desig     sdate          edate
1       aa       tt      10/03/2017     20/04/2017
2       aa       tt      21/04/2017     22/04/2017
3       aa       pp      23/04/2017     25/06/2017
4       bb       pp      15/03/2017     22/04/2017
5       bb       pp      22/04/2017     28/05/2017
6       bb       hh      29/05/2017     26/07/2017

我想输出这个

Sr no   name    desig   sdate         edate
1       aa       tt   10/03/2017    22/04/2017
2       aa       pp   23/04/2017    25/06/2017
3       bb       pp   15/03/2017    28/05/2017
4       bb       hh   29/05/2017    26/07/2017

上述输出的SQL查询是什么

1 个答案:

答案 0 :(得分:0)

使用这样的查询希望它能帮助你找到uniq行

select SrNo,name,desig,sdate,edate from tbl_name where convert(date,sdate) between convert(date,'3/16/2018') and convert(date,'3/17/2018') group by SrNo,name,desig,sdate,edate