什么意义,是返回一条记录吗?还是合成一个sql语句。

解决方案 »

  1.   

    写一个存储过程就行了,把这些sql语句写到存储过程里边
      

  2.   

    select a,b,c from m 
      union 
    select a,b,c from n
      

  3.   

    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 工号
      

  4.   

    使用存儲過程組成的sql 語句非常繁瑣
    多用 臨時表就成了
      

  5.   

    在语句之间加 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 工号应该可以的。
      

  6.   

    在C#中用:StringBuilder类对象
              命名空间: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 工号
    ");
      

  7.   

    select Distinct g.工号, 
    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 ,是为了防止漏掉有的员工,这样,即使没有以上纪录,也会出现该员工。
    关于条件,可能要限制每个表的时间,自己调试一下就知道了