我有一個表格,其列word, length, position, count and definition
。 我想要選擇word
和definition
,但只是保留一些單詞的定義(基於條件超過position
,count
和length
),其餘定義將其替換爲空字符串。SQL/SQlite:根據另一列的值在select語句中添加一列
我做下面的查詢:
SELECT word,definition FROM (SELECT word, definition, position, count FROM words
WHERE position = 5000 AND count < 5 AND length <= 6
AND definition IS NOT NULL
UNION ALL
SELECT word, "" AS definition, position, count FROM words)
ORDER BY position ASC, count DESC
但我最終列字重複值。
我怎樣才能得到這個沒有重複的值?
爲什麼不使用'CASE WHEN(condition)THEN definition ELSE「」END'? – Benoit