zoukankan      html  css  js  c++  java
  • sql三维数据

    今天有个钢铁项目在导入数据时 存货规格各种缺 想吐血

    原表结构是这样的 编码。规格。名称 三种存货 三种都有想同的规格 规格又分厚度和宽度 那么问题来了

    简简单单的几个厚度宽度 三种商品 就到了 1000多条记录 还确了好多 所以想了个办法 将一个表拆成三个表如下

     1 create table A_width
     2 (cWidth varchar(16) not null primary key)
     3 
     4 create table A_Height
     5 (cHeight varchar(16) not null primary key)
     6 
     7 create table A_InvName
     8 (id int identity primary key ,
     9 cinvName nvarchar(32),
    10 cInvAbb varchar(16))
    11 
    12 truncate table a_width
    13 insert into a_width values(20)
    14 insert into a_width values(21)
    15 insert into a_width values(22)
    16 insert into a_width values(23)
    17 
    18 insert into A_Height values(1000)
    19 insert into A_Height values(1200)
    20 insert into A_Height values(1300)
    21 insert into A_Height values(1400)
    22 
    23 truncate table a_invName
    24 insert into a_invName (cinvName,cinvAbb) values('原材','YC')
    25 insert into a_invName (cinvName,cinvAbb) values('半成品','BCP')
    26 insert into a_invName (cinvName,cinvAbb) values('成品','CP')
    27 
    28 create view inventory
    29 as
    30 select cinvName,cInvAbb+cWidth+cHeight cInvCode, cWidth+'*'+cHeight cinvStd 
    31 from a_height cross join A_width cross join a_invName
    
    39 select * from inventory


    其实就是三个数相乘

  • 相关阅读:
    python 文件目录/方法
    python文件
    python模块
    python数据结构
    python函数
    python迭代器和生成器
    python循环语句
    python控制语句 if
    python数字
    个人课程总结
  • 原文地址:https://www.cnblogs.com/SoftWareIe/p/6253165.html
Copyright © 2011-2022 走看看