现在有个需求
创建名为a的视图
a中的某项x的值由下面的条件决定
b表中的项目y如果有值则a中的x取b中的y
即if b.y !='' begin a.x=b.y end
如果b表中项目y为空且c表中的项目z有值则a的x取c的z
即if b.y='' and c.z!='' begin a.x=c.z end
大概思路是这样
自己在sql2000下写 ......
SQL code:
---测试数据---
if object_id('[t1]') is not null drop table [t1]
go
create table [t1]([姓名] varchar(2),[类别] varchar(2),[时间] varchar(12))
insert [t1]
select '张','A' ,'201001251730' union all
select '王','B' ,'201001261530' union all
select '王','B' ,'201001272130' union all
......
我用以下的语句,获取MAC :
create proc p_getlinkinfo
@dbname sysname=null,--要查询的数据库名,默认查询所有数据库的连接信息
@includeip bit=0--是否显示IP地址,因为查询IP地址比较费时,所以增加此控制
as
declare @dbid int
set @dbid=db_id(@dbname)
create table #tb(id int identi ......
"update lesson set name='15',age='15',gen='True',date='2010-02-28',city='上海',where id='15'"
where前面的逗号你觉得多余不?
不是这里的问题,去掉这个逗号,仍然提示,同样的错误,就提示sql文有错误
去掉where的逗号后语法上已经没错误了 ......
pl/sql :
delete from trap_urrshis where type=trap_type and cycle>=vcycle_code_begin
commit;
update table ....
commit;
......
表结构:
table1
证件号 时间
X31 2010-01-11
3BC 2010-02-03
3AD 2010-02-03
F23 2010-02-09
......
现在要统计一个时间段如 2010-01-09 到 2010-02-09间的数据,
期待结果:
日期 数量
2010-01-09 0
2010-01-10 0
2010-01-11 1
2010-01-12 0
...
2010-02-09 ......