Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql aGohil此查询生成的行的顺序与您的相同。如果要对CreatedDt进行降序排序,请在ORDER BY CreatedDt@DevendraGohil之后插入desc:我更新了答案,以说明如何为主要排序标准指定降序。(对不起,你的帖子中没有提到这一点。)_Sql_Sql Server_Sql Server 2008_Plsql - Fatal编程技术网

Sql aGohil此查询生成的行的顺序与您的相同。如果要对CreatedDt进行降序排序,请在ORDER BY CreatedDt@DevendraGohil之后插入desc:我更新了答案,以说明如何为主要排序标准指定降序。(对不起,你的帖子中没有提到这一点。)

Sql aGohil此查询生成的行的顺序与您的相同。如果要对CreatedDt进行降序排序,请在ORDER BY CreatedDt@DevendraGohil之后插入desc:我更新了答案,以说明如何为主要排序标准指定降序。(对不起,你的帖子中没有提到这一点。),sql,sql-server,sql-server-2008,plsql,Sql,Sql Server,Sql Server 2008,Plsql,aGohil此查询生成的行的顺序与您的相同。如果要对CreatedDt进行降序排序,请在ORDER BY CreatedDt@DevendraGohil之后插入desc:我更新了答案,以说明如何为主要排序标准指定降序。(对不起,你的帖子中没有提到这一点。) SELECT CreatedDt as 'Date/Time' , null AS [Alert_Type] FROM TblA union SELECT CreatedDt as 'Date/Time' , null AS [Alert


aGohil此查询生成的行的顺序与您的相同。如果要对CreatedDt进行降序排序,请在
ORDER BY CreatedDt
@DevendraGohil之后插入
desc
:我更新了答案,以说明如何为主要排序标准指定降序。(对不起,你的帖子中没有提到这一点。)
SELECT CreatedDt as 'Date/Time' , null AS [Alert_Type] FROM TblA
union  
SELECT CreatedDt as 'Date/Time' , null AS [Alert_Type] FROM TblB
union  
SELECT CreatedDt as 'Date/Time' , null AS [Alert_Type] FROM TblC
union
SELECT CreatedDt as 'Date/Time' , Alert_Type FROM TblD
ORDER BY CreatedDt, ISNULL (Alert_Type,'aa') DESC
ORDER BY items must appear in the select list if the statement contains a UNION, INTERSECT or EXCEPT operator.
ORDER BY  CASE WHEN column_name IS NULL
               THEN 1
               ELSE 0
          END ASC --, other sorts
                  -- in these case NULL columns should be on the bottom part
select * from (

SELECT CreatedDt as 'Date/Time' , null AS [Alert_Type] FROM TblA
union  
SELECT CreatedDt as 'Date/Time' , null AS [Alert_Type] FROM TblB
union  
SELECT CreatedDt as 'Date/Time' , null AS [Alert_Type] FROM TblC
union
SELECT CreatedDt as 'Date/Time' , Alert_Type FROM TblD)a
order by CreatedDt desc, 
         case when Alert_Type is null then 0 else 1 end
SELECT CreatedDt as 'Date/Time' , 'aa' AS [Alert_Type] FROM TblA
union  
SELECT CreatedDt as 'Date/Time' , 'aa' AS [Alert_Type] FROM TblB
union  
SELECT CreatedDt as 'Date/Time' , 'aa' AS [Alert_Type] FROM TblC
union
SELECT CreatedDt as 'Date/Time' , Alert_Type FROM TblD
ORDER BY CreatedDt DESC, Alert_Type DESC