由于笔者天生笨拙,且思维不严谨,也实在不擅长写sql语句,高手请勿见笑,就请直接跳过本文吧。
背景就不多介绍了,先建表,插入测试数据吧。字段那些都有注释
复制代码 代码如下:
–医生表
CREATE TABLE doctor
(
id INT IDENTITY(1, 1) , –ID 自增长
docNumber NVARCHAR(50) NOT NULL , –医生编码
NAME NVARCHAR(50) NOT NULL –医生姓名
)
go
–插入测试数据
INSERT INTO doctor
VALUES ( ‘007’, ‘Tom’ )
INSERT INTO doctor
VALUES ( ‘008’, ‘John’ )
INSERT INTO doctor
VALUES ( ‘009’, ‘Jim’ )
–号源表(挂号表)
CREATE TABLE Nosource
(
id INT IDENTITY(1, 1) ,
docNumber NVARCHAR(50) NOT NULL , –和医生表中的医生编码对应
workTime DATETIME NOT NULL
)
go
–插入测试数据
INSERT INTO Nosource
VALUES ( ‘007’, ‘20120819’ )
INSERT INTO Nosource
VALUES ( ‘007’, ‘20120820’ )
INSERT INTO Nosource
VALUES ( ‘007’, ‘20120821’ )
INSERT INTO Nosource
VALUES ( ‘008’, ‘20120821’ )
原创文章,作者:kepupublish,如若转载,请注明出处:https://blog.ytso.com/234614.html
赞 (0)