C# SQL语句查询问题
我的SQL语句如下:
"Select Count(Distinct YWBH) As ZS, Sum(MJ) As MJH,Sum(JG) As JGH, DM From [TJ_SJ] Where RQ>=#2008-11-08# And RQ<=#2008-12-08# And (DM='05' Or DM='06' Or DM='08' Or DM='09' Or DM='10' Or DM='11') Group By DM"
在用DataReader时出现如下错误提示:
"语法错误 (操作符丢失) 在查询表达式 'Count(Distinct YWBH)' 中。"
如果把SQL语句中的Count(Distinct YWBH) 改为Count(YWBH),则能正常运行,但是不能达到我的预期功能。请问该如何解决这个问题?
------解决方案--------------------access不支持Count(Distinct YWBH),这个市sqlserver的
------解决方案--------------------YWBH是什么类型的?
建议用select YWBH ....这样的语句,结果保存到List中,然后用List<>.Distinct().Count得出YWBH的个数
------解决方案--------------------
select count(YWBH) as counts,sum(MJ) as MJs,sum(JG) as JGs
from 表
group by YWBH
order by YWBH