1、多个查询结果按行显示
select max(Objectid) as Objectid from [tableName] union all
select min(Objectid) as Objectid from [tableName];
查询结果如下
如果觉得查出来的结果区分不开,可以在前面加上区分字段,代码如下:
select 'Objectid1',max(Objectid) as Objectid from [tableName] union all
select 'Objectid2', min(Objectid) as Objectid from [tableName];
查询结果如下:
这里需提醒的是用union all连接的sql语句select查询后跟的查询内容个数需保持一致
2、多个查询结果按列并列显示
写法一:
select
(select max(Objectid) from [tableName]) as Objectid1 ,
(select min(Objectid) from [tableName]) as Objectid2;
查询结果展示如下:
写法二:
select bsm1,bsm2 from (
(select 1 id, max(Objectid) as Objectid1 from [tableName]) X left join
(select 1 id, min(Objectid) as Objectid2 from [tableName]) Y on X.id=Y.id)
写法二使用的left join,结果与写法一一样。
注:以上拼接的两个sql语句只是示例