在“计算机公司”数据库中解决站点https://www.sql-ex.ru/上的一项 sql 任务时,解决方案是使用case when
.
我想知道为什么给定的条件不起作用,即 解决方案没有通过附加基地的测试?
select p.maker,case when max(case when t.price is null then 0 else 1 end)=1 then max(t.price) end as m_price from product p...`
虽然结果是正确的,
而且这个解决方案是正确的:
select p.maker,case when max(case when t.price is null then 1 else 0 end)=0 then max(t.price) end as m_price from product p...
那些。区别就在这里:
case when max(case when t.price is null then 0 else 1 end)=1 then max(t.price) end
case when max(case when t.price is null then 1 else 0 end)=0 then max(t.price) end
-第二个条件是正确的结果,
因为理论上 1 和 0 在条件中的位置并不重要then и else
?
还是我需要展示整个任务?
它们是有区别的
你的第二个类似物应该看起来像