初学者,向大侠们请教一个sql语句如何写,描述如下:
有三个表tab1,tab2,tab3.
三个表中都有code(代码)和date(日期)这两列,
其中code是关键字,
现在我想选出三个表中code字段相同时所有不重复的date数据,按照从大到小的顺序输出,
请教一下该如何写这个sql语句啊
有三个表tab1,tab2,tab3.
三个表中都有code(代码)和date(日期)这两列,
其中code是关键字,
现在我想选出三个表中code字段相同时所有不重复的date数据,按照从大到小的顺序输出,
请教一下该如何写这个sql语句啊
union
select code,date from tab2
union
select code,date from tab3 order by code,date
(
select code,date from tab1
union
select code,date from tab2
union
select code,date from tab3 order by code,date
)t
(
select code,date from tab1
union all
select code,date from tab2
union all
select code,date from tab3 )t
order by code,date
union all
select code,date from tab2
union all
select code,date from tab3 order by code,date
union all
select code,date from tab2
union all
select code,date from tab3
order by code,date