[英]Multiple Case conditions in where clause
I have a table where there 2 columns. 我有一张桌子,那里有2列。 F1 and F2. F1和F2。 Now F1 has Id and F2 has score. 现在,F1具有ID,F2具有得分。
F1 Score
1 10
1 20
6 10
now I want to have a where clause where it considers 6 as 1 and adds them with 1 现在我想要一个where子句,其中将6视为1并将它们加1
for example when I use when F1=1 it should give 例如当我使用F1 = 1时
F1 Score
1 10
1 20
1 10
I have used 我用过
WHERE (F1 = CASE WHEN F1 =6 THEN 1 ELSE F1 END ) 在哪里(F1 =当F1 = 6然后THEN 1 ELSE F1 END的情况)
but not working. 但不起作用。
You seem to want: 您似乎想要:
select (case when f1 = 6 then 1 else f1 end) as new_f1,
score
from t
order by new_f1;
EDIT: 编辑:
You changed the question. 您改变了问题。 For filtering, you would simply do: 对于过滤,您只需执行以下操作:
where f1 in (1, 6)
Try this: 尝试这个:
select (case when F1 = 6 then 1 else F1 end) as something, SCORE
from your_table
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.