【发布时间】:2012-11-13 19:29:14
【问题描述】:
我有这个代码:
select
B.plc_nomeConta, B.plc_classificador, B.plc_id,
A.cap_idPlanoContasFin, SUM(A.cap_valorfatura) as Total
from
tbl_PlanoFinanceiro B
left outer join erp_contaspagar A on B.plc_id = A.cap_idPlanoContasFin
/* where A.cap_idEmpresa like 2*/
group by
B.plc_nomeConta,
B.plc_classificador,
B.plc_id,
A.cap_idPlanoContasFin
此代码返回 185 行,
(-) COFINS 10.01.01.01.004 330 330 971090,97
(-) ICMS 10.01.01.01.002 328 328 1378407,11
(-) IMPOSTOS 10.01.00.00.000 324 NULL NULL
(-) IMPOSTOS 10.01.01.00.000 325 NULL NULL
(-) IMPOSTOS 10.01.01.01.000 326 NULL NULL
(-) ISS 10.01.01.01.001 327 327 1000960,59
(-) PIS 10.01.01.01.003 329 329 240600,27
但是当我取消注释 where /* where A.cap_idEmpresa like 2*/ 时,只返回出现 A.cap_idPlanoContasFin is not null、需要 B.plc_nomeConta, B.plc_classificador, B.plc_id 的行。
【问题讨论】:
-
试试
AND而不是WHERE。
标签: sql sql-server sql-server-2008