看看SQL有什么问题? - MS-SQL Server / 基础类
int year = DateTime.Now.Year;
int month = DateTime.Now.Month;
int day = DateTime.Now.Day;
今天的信息总和
select count(id) from info where year(addtime)="+year+" and month(addtime)="+month+" and day(addtime)="+day+"
昨天的信息总和
select count(id) from info where year(addtime)=" + year + " and month(addtime)=" + month + " and day(addtime)=" + (day - 1) + "
现在发现在不同时间执行上面昨天的SQL总和居然得到结果不同。SQL有问题吗?
单从你的代码看,没看出异常,你可以换用datediff的方式对比看看。
相关问答:
tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......
1。怎样使xp_cmdshell能完整输出超过255个字符的字符串。
2。select 时,检索速度是与from后的 TABLE顺序有关,还是与where条件的顺序有关(TABLE数据多少 )
在系统属性设定里有个选项,可以修改单字段输出字数限制. ......
有这样一条SQL
Select Get_Costtaxrate(col1), Get_Tcostvalue(col1) from a
其中Get_Costtaxrate、Get_Tcostvalue都是函数,这两个函数里面都是查找一个大表,Get_Tcostvalue还需要调用Get_C ......
现在有一个部门表dept(部门名称,部门号。。)有一个人员表emp(姓名,人员编号,职位,薪资,部门)
emp表中的内容是这样的:
a 1 工程师 3000 软件部
b 2 普通员工 2000 硬件部
c 3 工程师 4000 硬件部
d ......