我使用以下查询:
SELECT *
FROM
(
SELECT
column1,
column2,
column3
FROM
table
WHERE value NOT IN(
'v1',
'v2',
)
AND column1 = 'c1'
AND column2 IN(
'c2',
'c21',
'c22',
)
) pivot(
MAX(column) FOR(c) IN(
'c2' ,
'c21' ,
'c22' ));
现在,我想添加此脚本以计算其他列:
SELECT column, COUNT(*) FROM table WHERE column1='c1' AND column2='c2'
AND column in(
SELECT a.column FROM table a, table b WHERE a.column1='c1' AND a.column2='c2'
AND b.column NOT IN (c1, c2));
有人可以告诉我该怎么做吗?
谢谢。