我有以下表格
tab_1:
(rs)
rs1
rs2
rs3
tab_2:
(rs) (cell) (tf)
rs1 A549 tf1
rs1 C555 tf2
rs3 B333 tf1
我需要在 tab_1 only 列上循环并检查:
SELECT count(distinct cell) from tab_2 where rs = 'rs1'
union all
SELECT count(distinct cell) from tab_2 where rs = 'rs2'
union all
SELECT count(distinct cell) from tab_2 where rs = 'rs3';
并得到结果
2
0
1
无法理解光标应该如何工作或只是一个简单的循环(