本文介绍了查找所有记录,即使它们没有价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我有一个查询,必须通过VIA找到值
Hi
I have a query that has to find values VIA
select distinct strclient,
SUM(intTotalValue) as Total
from tblBatch
where
Year(dtmDateTransmitted) = 2012
and MONTH(dtmDateTransmitted) = 6
group by strClient
因此,当我运行查询时,我需要没有值的客户端和没有值的客户端.
我需要它才能在SQL Server 2008中运行.
有任何建议吗?
So when I run the query I need the clients that don''t have values as well as the ones that do.
I need this to run in SQL server 2008 .
any suggestions?
推荐答案
select distinct Clients,
SUM(COALESCE (intTotalValue,0)) as TotalForMonth
from TblPayments
SELECT DISTINCT strclient,
SUM(ISNULL(intTotalValue, 0)) AS Total
FROM tblBatch
WHERE
YEAR(dtmDateTransmitted) = 2012
AND MONTH(dtmDateTransmitted) = 6
GROUP BY strClient
--Amit
--Amit
这篇关于查找所有记录,即使它们没有价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!