1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] Insert unique records into table based on calculation of other table column MYSQL

Discussão em 'Outras Linguagens' iniciado por Stack, Agosto 12, 2021.

  1. Stack

    Stack Membro Participativo

    I have two tables(ProductionDetails, Production), I need to populate Production based on calculated values of the ProductionDetails. ProductionDetails has the number of buckets gathered, Production needs to be populated with BINS. For example if I have 100 buckets, and I divide those by 30 that equals 3.33 bins. Now I need to create 3 BINS.

    select Round( sum(ep.Buckets)/30),ep.lot,ep.crewid
    from On_EmpProdDetails ep
    group by ep.buckets, ep.lot,ep.crewid


    Results in

    Bins​
    Lot​
    Crew
    3​
    556790186SOCC1​
    SOCC1​

    Now I want to insert 3 unique rows into the Production Table
    BinID is auto increment

    BinID​
    LOT
    1​
    556790186SOCC1
    2​
    556790186SOCC1
    3​
    556790186SOCC1​

    Continue reading...

Compartilhe esta Página