sqlserver语句建表数据库等等

USE master
go

--drop database b2019dc
--go

create database b2019dc  ----创建数据库b2019dc
 ON  PRIMARY 
(
FILENAME = N'd:\data\b2019dc.mdf',name =N'b2019dc.mdf'   --放在D盘data目录下
)
go

use b2019dc   --切换到这个数据库
go

--drop table t_m1   ----删除这个表
--go

create table t_m4(
	id bigint identity(1,1) not null,
	InstrumentID nvarchar(max) not null default '',
	TradingDay date not null default getdate(),	
	UpdateTime time(0) not null default getdate(),
	LastPrice decimal(18, 2) not null default 0,
	PreClosePrice decimal(18, 2) not null default 0,
	OpenPrice decimal(18, 2) not null default 0,
	HighestPrice decimal(18, 2) not null default 0,
	LowestPrice decimal(18, 2) not null default 0,
	Volume int not null default 0,
	LowerLimitPrice decimal(18, 2) not null default 0,
	primary key(id)
)
go

create table t_m13(
	id bigint identity(1,1) not null,
	InstrumentID nvarchar(max) not null default '',
	TradingDay date not null default getdate(),	
	UpdateTime time(0) not null default getdate(),
	LastPrice decimal(18, 2) not null default 0,
	PreClosePrice decimal(18, 2) not null default 0,
	OpenPrice decimal(18, 2) not null default 0,
	HighestPrice decimal(18, 2) not null default 0,
	LowestPrice decimal(18, 2) not null default 0,
	Volume int not null default 0,
	LowerLimitPrice decimal(18, 2) not null default 0,
	primary key(id)
)
go

select count(*) from t_m5

select * from t_m5
delete from t_m5


select * from (select *,volume - lag(volume,1,0) over (partition by InstrumentID,tradingday order by InstrumentID asc, tradingday asc , volume asc ) as tmpvol from t_m1 ) as tmp_t1 where  tmpvol <> 0 order by instrumentid asc, tradingday asc, Volume asc


--下面作废
--select TradingDay,InstrumentID,LastPrice,PreClosePrice,OpenPrice,HighestPrice,LowestPrice,Volume,LowerLimitPrice,UpdateTime,vol from
--(
--    select top 1000000000 *, (
--                            volume - LAG(volume, 1,0) over (order by instrumentid asc, tradingday asc, Volume asc)
--                        )
--    as vol from t_m7
--) as tmpvol
--where vol > 0 order by instrumentid asc, tradingday asc, Volume asc

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值