查询最近10天开户的银行卡的信息,利用datediff()函数,计算开户日期和当前日期相差的天数

2015-09-23 0 334
查询最近10天开户的银行卡的信息,利用datediff()函数,计算开户日期和当前日期相差的天数

if exists(select * from sysobjects where name = ’accountInfo’)
 drop table accountInfo
go

create table accountInfo
(
 custId int identity(1,1) primary key,   –账户编号
 custName varchar(20) not null,          –账户名称
 idcard varchar(18) not null,            –身份证号
 tel varchar(13) not null,               –电话
 custaddress varchar(50)                 –家庭住址
)
go
–插入数据
insert into accountInfo values(’李明博’,’423625198003253695’,’13035642815’,’武汉’)
insert into accountInfo values(’张小璐’,’424625198111253695’,’13035642816’,’南京’)
insert into accountInfo values(’王明山’,’425625197903223695’,’13035642817’,’北京’)
go

———————————-卡片信息表————————————

if exists(select * from sysobjects where name = ’cardInfo’)
 drop table cardInfo
go

create table cardInfo
(
 cardId varchar(19) primary key,                 —卡片编号
 cardpwd varchar(6) default(’888888’) not null,  —密码
 custId int references accountInfo(custId),      –账户编号(外键)
 saveType varchar(10) not null,                  –储蓄类型
 openDate datetime default(getdate()) not null,  –开户时间
 openmoney money not null check(openmoney>=1),   –开户余额
 leftmoney money not null check(leftmoney>=1),   –账户余额
 isloss varchar(2) default(’否’) not null        –是否挂失

go
–插入数据

insert into cardInfo values(’9559 3652 8425 1234’,default,1,’定期’,default,500,500,default)
insert into cardInfo values(’9559 3652 8425 1245’,default,2,’定期’,default,1300,1300,default)
insert into cardInfo values(’9559 3652 8425 1268’,default,3,’定期’,default,8500,8500,default)
go

———————————————交易信息表———————————-

if exists(select * from sysobjects where name = ’transInfo’)
 drop table transInfo
go

create table transInfo
(
 cardId varchar(19)  references cardInfo(cardId),                                  –卡片编号(外键)
 transType varchar(4) not null check(transType = ’支取’ or transType = ’存入’),    –交易类型
 transmoney money not null,                                                        –交易金额
 transDate datetime default(getdate()) not null                                    –交易时间
)
go

 

select * from transInfo

 

–查询表
select * from accountInfo
select * from cardInfo
select * from transInfo

怎么写?求帮助

遇见资源网 sql 查询最近10天开户的银行卡的信息,利用datediff()函数,计算开户日期和当前日期相差的天数 http://www.ox520.com/17865.html

上一篇: 图书馆剔旧
下一篇: SQL Server延时
常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务