sql求助 - MS-SQL Server / 疑难问题
ID 人员ID 起始日期 终止日期 办事处 调整原因
1 1001 2010-1-1 2010-3-31 南京 业务需要
2 1001 2010-4-1 至现在 上海 <null>
3 1002 2010-2-1 2010-3-28 广州 不适应
4 1002 2010-3-29 至现在 珠海 <null>
现在有个需求:
比如:我输入:2010-3-1 -----2010-3-31
得到的统计表是:
人员ID 调整日期 调整描述 调整原因
1002 2010-3-28 广州----珠海 不适应
1001 2010-3-31 南京----上海 业务需要
通过SQL语句实现.
SQL code:
create proc aaa @stime datetime,@etime datetime
select * from tb where 起始日期>@stime and 终止日期<@etime
看错了,不好意思
你输入的时间是在哪里输入?作为存储过程的参数还是直接放入sql语句中
where 终止日期 between '2010-3-1' and '2010-3-31'
SQL code:
create table #test(ID int,人员ID int,起始日期 datetime,终止日期 datetime,办事处 varchar(20),调整原因 varchar(20))
insert #test select 1 ,1001 ,'2010-1-1','2010-3-31', '南京', '业务需要'
insert #test select 2 ,1001 ,'2010-4-1',getdate(), '上海', null
insert #test select 3 ,1002 ,'2010-2-1',' 2010-3-28',
相关问答:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
从数据库中查询一张表的数据
select 部门,姓名 from tb
如何才能生成下面的xml格式
XML code:
<folder state="unchecked" label="全部">
<folder state="unchecked&qu ......
现在有两张表:文章主表A(articleId,articleTitle),文章评论表B(commentId,articleId,commentTitle)
现在我想实现这样的功能:列出文章列表,其中每篇文章标题下面列出此文章的前2个文章评论,请问sql语句怎么写啊 ......
查询学生平均成绩及其名次
SELECT 1+(SELECT COUNT( distinct 平均成绩)
from (SELECT S#,AVG(score) AS 平均成绩
from SC&n ......