什么意义,是返回一条记录吗?还是合成一个sql语句。
解决方案 »
- C#如何验证一个邮箱是否真实存在 不是格式是否正确
- C# 插入时this.textbox1.text为空时就出错了
- 摄像头拍照 保存为1寸照片
- 一个问题 高手一定要路过,要不我就死定了!在线等等急急急!!!
- c#怎么实现 复制,粘帖?
- 我想用sql建立一个表
- 【2000分】【在线等待】【急急急】如何获取方法体的字节码?
- 过滤datatable
- C#.net在非Win2000环境下出错的问题
- 关于C#的电子书那里有下.......
- 快帮我这段程序,关于ParameterName“@categoryid”的 SqlParameter问题.只要能解决问题,分不是问题.
- 为什么自定义控件的属性没有显示出来??
union
select a,b,c from n
union
select Distinct 工号,sum(应扣工时) as 应扣工时 from 员工早退记录 where 工号>='19930820001' and 工号<='20000628004' and 日期>='2003-3-8' and 日期<='2003-2-12' group by 工号
多用 臨時表就成了
UNION
select Distinct 工号,sum(应扣工时) as 应扣工时 from 员工早退记录 where 工号>='19930820001' and 工号<='20000628004' and 日期>='2003-3-8' and 日期<='2003-2-12' group by 工号应该可以的。
命名空间:using System.Text
StringBuilder text=new StringBuilder();
text.Append("select Distinct 工号,sum(应扣工时) as 应扣工时 from 员工迟到记录 where 工号>='19930820001' and 工号<='20000628004' and 日期>='2003-3-8' and 日期<='2003-2-12' group by 工号")text.Append("select Distinct 工号,sum(应扣工时) as 应扣工时 from 员工早退记录 where 工号>='19930820001' and 工号<='20000628004' and 日期>='2003-3-8' and 日期<='2003-2-12' group by 工号
");
sum(a.应扣工时)+sum(b.应扣工时)+sum(c.应扣工时)+sum(d.应扣工时) as 应扣工时,
sum(e.计时数)+sum(f.计时数) as 计时数,
sum(e.实得工时数)+sum(f.实得工时数) as 实得时数
from 员工迟到记录 a ,员工早退记录 b,员工溜班记录 c,员工旷工记录 d,请假资料管理 e,出差资料表 f ,员工列表 g
where g.工号>='19930820001' and g.工号<='20000628004'
and 日期>='2003-3-8' and 日期<='2003-2-12'
group by 工号我添加了一个员工列表 g ,是为了防止漏掉有的员工,这样,即使没有以上纪录,也会出现该员工。
关于条件,可能要限制每个表的时间,自己调试一下就知道了