例表如下:
姓名 部门 职级 工资等级
张三 1 A 01
李四 2 A ......
数据
|Field1| Field2| Field3|
| F1 | x1 1
| F2 | xx1 3
| F1 | x1 2
| F1 | x2 & ......
我有一个表,里面包含有很多用户每次的摇奖记录,
username d1 d2
aa 4 5
bb 4 2
aa & ......
SQL code:
SELECT cls.*, yplan.*
from Mpt_CostItem cls INNER JOIN
Mpt_YearPlan yplan ON cls.CostItem_ID = yplan.YearPlan_ItemID
GROUP BY yplan.YearPlan_ItemID
ORDER BY yplan.YearPlan_ID
上面的语运行肯定是通不过的如果改成这样
SQL code:
SELECT max(cls.字段), max(yplan.字段)
f ......
exec ( 'select sum(JiHua_Count) from JiHua_Msg where'+ @SqlWhere)
执行存储过程时,一直报 “第 1 行: '2009-11-02' 附近有语法错误。 ” 不知道该如何解决?
参数 @SqlWhere 的内容是 IsDelete=0 and ( JiHua_Time between '2009-11-02' and '2009-1 ......
select a.strno,a.strnam,b.sum(score) from
(select strno,strnam from name where strnam >2) a,
(select strno,sum(score) from score where strdate>'1-1月-2009' group by strno having sum(score)>300) b
where a.strno=b.strno group by a.strno,a.strnam
表A中是学号和学名,表B ......