SQL Server CASE .. WHEN .. IN statement

前端 未结 4 1010
我在风中等你
我在风中等你 2020-12-10 00:26

On SQL server 2005 I am trying to query this select statement

SELECT AlarmEventTransactionTableTable.TxnID,
       CASE AlarmEventTransactions.DeviceID
             


        
4条回答
  •  自闭症患者
    2020-12-10 01:09

    Thanks for the Answer I have modified the statements to look like below

    SELECT
         AlarmEventTransactionTable.TxnID,
         CASE 
        WHEN DeviceID IN('7', '10', '62', '58', '60',
                '46', '48', '50', '137', '139',
                 '141', '145', '164') THEN '01'
        WHEN DeviceID IN('8', '9', '63', '59', '61',
                '47', '49', '51', '138', '140',
                '142', '146', '165') THEN '02'
                 ELSE 'NA' END AS clocking,
         AlarmEventTransactionTable.DateTimeOfTxn
    FROM
         multiMAXTxn.dbo.AlarmEventTransactionTable
    

提交回复
热议问题