h-you / branches / ddl / 20180323_SQL.txt @ 371
履歴 | 表示 | アノテート | ダウンロード (1.67 KB)
1 |
-- ?S????????????f?[?^ |
---|---|
2 |
drop table if exists ChgChargeDep cascade; |
3 |
|
4 |
create table ChgChargeDep ( |
5 |
PersonCode decimal(8,0) not null comment '?S????R?[?h' |
6 |
, StartDate date not null comment '?J?n?N????' |
7 |
, CompDate date not null comment '?I???N????' |
8 |
, DepartmentCode decimal(5,0) unsigned not null comment '?????R?[?h' |
9 |
, DepartmentName varchar(60) comment '??????' |
10 |
, EntryDate datetime not null comment '?o?^???t' |
11 |
, UpdateDate datetime not null comment '?X?V???t' |
12 |
, constraint ChgChargeDep_PKC primary key (PersonCode, StartDate) |
13 |
) comment '?S????????????f?[?^' ; |
14 |
|
15 |
Insert INTO ChgChargeDep |
16 |
select |
17 |
A.PersonCode |
18 |
, A.StartDate |
19 |
, A.EndDate |
20 |
, A.DepartmentCode |
21 |
, B.DepartmentString |
22 |
, Now() |
23 |
, Now() |
24 |
From |
25 |
personinchargemaster As A |
26 |
Left Join departmentmaster As B |
27 |
On B.DepartmentCode = A.DepartmentCode |
28 |
; |
29 |
|
30 |
update chgchargedep Set CompDate = DATE('2017/07/31'), DepartmentCode = 2, DepartmentName = '?c?U??' Where PersonCode = 20150701 And DATE(StartDate) = DATE('2015/07/01'); |
31 |
Insert chgchargedep Value(20150701, DATE('2017/08/01'), DATE('0001/01/01'), 1, '?H????', NOW(), NOW()); |
32 |
|
33 |
update chgchargedep Set CompDate = DATE('2017/07/31'), DepartmentCode = 1, DepartmentName = '?H????' Where PersonCode = 20160602 And DATE(StartDate) = DATE('2016/06/20'); |
34 |
Insert chgchargedep Value(20160602, DATE('2017/08/01'), DATE('0001/01/01'), 3, '?c???', NOW(), NOW()); |
35 |
|
36 |
update chgchargedep Set CompDate = DATE('2017/07/31'), DepartmentCode = 1, DepartmentName = '?H????' Where PersonCode = 20160701 And DATE(StartDate) = DATE('2016/07/01'); |
37 |
Insert chgchargedep Value(20160701, DATE('2017/08/01'), DATE('0001/01/01'), 2, '?c?U??', NOW(), NOW()); |
38 |
commit; |