sql怎么查詢一個列的最大值?
方法一SELECTID,Name,(SELECTMAX(LastUpdateDate)FROM(VALUES(UpdateByApp1Date),(UpdateByApp2Date),(UpdateByApp3Date))ASUpdateDate(LastUpdateDate))ASLastUpdateDateFROM##TestTable方法二SELECTID,[Name],MAX(UpdateDate)ASLastUpdateDateFROM##TestTableUNPIVOT(UpdateDateFORDateValIN(UpdateByApp1Date,UpdateByApp2Date,UpdateByApp3Date)
)ASuGROUPBYID,Name方法三SELECTID,name,(SELECTMAX(UpdateDate)ASLastUpdateDateFROM(SELECTtt.UpdateByApp1DateASUpdateDateUNIONSELECTtt.UpdateByApp2DateUNIONSELECTtt.UpdateByApp3Date)ud)LastUpdateDateFROM##TestTablett
上一篇列向量長度為1是什么意思
下一篇數據不可分割的基本單位是