我有一个包含大量数据的表,从查询中我可以获得我正在查看的值,但在我查询时我在桌面上获得了一般计数
SELECT (CODISTRITO + CODMANZANA+CODLOTE)AS CODMAN,
(SELECT count(TYPE) from dbo.test WHERE TYPE = 'ABC') as ABC,
(SELECT count(TYPE ) from dbo.test WHERE TYPE = 'DEF') as DEF,
(SELECT count(TYPE ) from dbo.test WHERE TYPE = 'GHI') as GHI,
(SELECT count(TYPE ) from dbo.test WHERE TYPE = 'JKL') as JKL
FROM dbo.test
CODEMAN ABC DEF GHI JKL
1234567 1000 4000 6000 8000
1234578 1000 4000 6000 8000
1234579 1000 4000 6000 8000
1234510 1000 4000 6000 8000
1234511 1000 4000 6000 8000
1234512 1000 4000 6000 8000
1234513 1000 4000 6000 8000
我想有一张桌子,我可以看到ABC,DEF,GHI,JKL(如下所示)的个别数量:
CODEMAN ABC DEF GHI JKL
1234567 200 1000 1000 1000
1234578 100 500 1000 2000
1234579 300 500 2000 1000
1234510 50 700 500 1000
1234511 150 300 500 1000
1234512 200 500 500 1000
1234513 100 500 500 0
如果您在ABC中的每个值的总和是= 1000等(那么是一般计数),就像我在第一个表中那样
答案 0 :(得分:1)
您可以使用条件聚合执行此操作:
npm start