解决方案 »
- 下面两个查询,哪个效率高些?(一个是连接后再筛选,一个是筛选后再连接)
- 客户端长时间不操作, SQL Server连接被断开,如何解决?
- 如何将ACCESS数据库的数据移植到SQL数据库中
- 怎么样能看到SQL2000的密码
- 急。。。。。。。。。。。。。。。。。。。。
- 合并多条记录为一条
- 有关全文索引 "所选表中没有 在不允许 NULL 的列上的唯一单个列索引。"
- 还是CHAR和VARCHAR问题
- 求助:怎么把一个表的满足条件的记录放到另一个表呢????
- 我不是狂人,我无知,但我还是想问问:作为三大基础软件之一的数据库系统,中国人不能做吗?在技术上是不是更容易突破?争取市场是不是更有可能?没什么没看到成功的产品?有人可能告诉我原因吗?
- C# 与 sql server 无线局域网的相关问题~
- SQL语句求详细解释
create table TableA(ID int, Station nvarchar(10),endTime datetime,rdLong int , RdDate nvarchar(20))
go
insert into tablea select 1,'3#筒仓','2014-01-01 05:45:52.530',9.00,null
insert into tablea select 2,'3#筒仓','2014-01-02 07:36:15.937',9.00,null
insert into tablea select 3,'1#筒仓','2014-01-03 15:08:18.780',42.00,null
insert into tablea select 4,'1#筒仓','2014-01-04 18:08:08.970',42.00,null
insert into tablea select 5,'1#筒仓','2014-01-05 21:08:04.767',43.00,null
go
update TableA set RdDate=
(case when convert(varchar(5),endTime,114)>'17:30' then convert(varchar(10),endTime,120)+' 夜班'
when convert(varchar(5),endTime,114)<'07:30' then convert(varchar(10),dateadd(d,-1,endTime),120)+' 夜班'
else convert(varchar(10),endTime,120)+' 日班'
end)
select * from tablea
/*
ID Station endTime rdLong RdDate
----------- ---------- ----------------------- ----------- --------------------
1 3#筒仓 2014-01-01 05:45:52.530 9 2013-12-31 夜班
2 3#筒仓 2014-01-02 07:36:15.937 9 2014-01-02 日班
3 1#筒仓 2014-01-03 15:08:18.780 42 2014-01-03 日班
4 1#筒仓 2014-01-04 18:08:08.970 42 2014-01-04 夜班
5 1#筒仓 2014-01-05 21:08:04.767 43 2014-01-05 夜班(5 行受影响)*/
go
drop table tablea
case when convert(varchar(5),endTime,114)>'07:30' and convert(varchar(5),endTime,114)<'17:30'
then convert(varchar(10),endTime,120)+'日班'
else convert(varchar(10),endTime,120)+'夜班' end