2017-10-17 110 views
-4

我很難選擇持續時間 當狀態是1或當狀態是4時SQL案例條件?

我如何查詢它?

enter image description here

+4

'SELECT的持續時間從yourTable WHERE狀態IN(1,4)'......那麼難? –

+2

'選擇持續時間from your_table where state = 1 or state = 4'? –

回答

4

您可以選擇在WHERE子句多個值:

SELECT duration 
FROM <Table_Name> 
WHERE state in (1, 4) 
-1

其實你需要一個WHERE子查詢使用OR運算符來做到這一點:

SELECT Duration FROM tablename WHERE State = 1 OR State = 4