select count(case when a = 1 then b end) as 'a=1', count(case when a = 2 then b end) as 'a=2', count(case when a = 3 then b end) as 'a=3', count(case when a = 4 then b end) as 'a=4' from dna
不能在ACCESS中用,ACCESS的SQL不标准,用了好多VB函数。改一下就能用了。 select count(IIf( a = 1,b,null ) as 'a=1', count(IIf( a = 2, b, null) as 'a=2', count(IIf( a = 3, b, null) as 'a=3', count(IIf( a = 4, b, null) as 'a=4' from dna
SELECT count( IIf( a = 1,b,null )) AS ['a=1'], count(IIf( a = 2, b, null)) AS ['a=2'], count(IIf( a = 3, b, null)) AS ['a=3'], count(IIf( a = 4, b, null)) AS ['a=4'] FROM dna;
SELECT count(IIf( a = 1, b, null)) AS [a=1], count(IIf( a = 2, b, null)) AS [a=2], count(IIf( a = 3, b, null)) AS [a=3], count(IIf( a = 4, b, null)) AS [a=4] FROM dna; 你要是单机版处理数据库问题要么来个大而全的SQL server 2005 要么来个SQLite ACCESS的SQL最烦人了,很多不标准的地方。