日期:2014-05-18  浏览次数:20535 次

数据库查询出问题
select distinct 物料名称= FItemID,金额=sum(FAmount) from vwICBill_1 where FDate like '2009-01%' group by FItemId

语句正确执行 但是没有结果 是在+入like‘2009-01’后出的错,请指点、、、、、

------解决方案--------------------
SQL code

select 
distinct 物料名称= FItemID,金额=sum(FAmount) from vwICBill_1 
convert(varchar(10),FDate,120)  like '2009-01%' 
group by FItemId

try

------解决方案--------------------
select distinct 物料名称= FItemID,金额=sum(FAmount) from vwICBill_1 where FDate like '[2009-01]%' group by FItemId

试试
------解决方案--------------------
SQL code
select distinct 物料名称= FItemID,金额=sum(FAmount) from vwICBill_1 where convert(varchar(7),FDate,120)='2009-01' group by FItemId