0
我有源表Test
包含id
列,目标表testm
由id , col2
组成。请帮助我摆脱这个错误。在case语句中缺少表达式错误
test (source)
id
---
10
10
20
20
20
30
30
40
目标
testm
id col2
-- ----
10 1
10 2
20 1
20 2
20 3
30 1
30 2
40 1
查询:
select id, (case id
when 10 then select count(id) from test where id =10
when 20 then select count(id) from test where id =20
when 30 then select count(id) from test where id =30
when 40 then select count(id) from test where id =40
else 0 END) col2 from test
引发错误:
missing expression
喜@ jpw感谢您的快速回复。它满足了我的要求。是否有可能通过case语句实现相同的o/p?感谢您的解决方案。 – affable
@affable我不认为这是可能的案件陈述,至少我想不出任何方式。 – jpw