Sqlserver
 sql >> डेटाबेस >  >> RDS >> Sqlserver

SQL सर्वर 2008 निर्दिष्ट कॉलम कई बार निर्दिष्ट किया गया था

QISProduct से जुड़ी गणना की गई क्वेरी में दो तालिकाओं यानी QISEventLog और QISProcess से आईडी कॉलम होता है। तो उन कॉलम का नाम बदलकर अलग-अलग नाम कर दें। अपडेट की गई क्वेरी

        SELECT g.artcode
            ,sum(g.aantal)
            ,i.class_01
            ,i.Isstockitem
        FROM gbkmut AS g
        INNER JOIN items AS i ON i.itemcode = g.artcode
        INNER JOIN (
            SELECT QISP.id
                ,QISprocess.nml AS Processnml
                ,QISeventlog.id AS EventLogId
                ,QISeventlog.dtsample
                ,QISproduct.nms
                ,QISbatchlog.nm AS batchnm
                ,QIStestlog.idvariable
                ,QIStestlog.no
                ,QISshortnote.ds
                ,gewicht = CASE QIStestlog.IDvariable
                    WHEN '139'
                        THEN QIStestlog.no
                    END
                ,aantal = CASE QIStestlog.IDvariable
                    WHEN '234'
                        THEN QIStestlog.no
                    END
                ,siloleeg = CASE QIStestlog.idvariable
                    WHEN '23'
                        THEN CASE QIStestlog.no
                                WHEN '10'
                                    THEN 'Ja'
                                ELSE 'Nee'
                                END
                    END
                ,QISvariable.nml variablenml
                ,gl.nm AS glnm
                ,QISprocess.id AS ProcessId
            FROM QIC.Vobra_new2.dbo.production AS QISP
            INNER JOIN QIC.Vobra_new2.dbo.process AS QISprocess ON QISP.idprocess = QISProcess.id
            INNER JOIN QIC.Vobra_new2.dbo.product AS QISproduct ON QISP.idproduct = QISproduct.id
            INNER JOIN QIC.Vobra_new2.dbo.batchlog AS QISbatchlog ON QISP.idbatch = QISbatchlog.id
            INNER JOIN QIC.Vobra_new2.dbo.eventlog AS QISeventlog ON QISeventlog.idproduction = QISP.id
                AND QISeventlog.idbatch = QISbatchlog.id
            INNER JOIN QIC.Vobra_new2.dbo.testlog AS QIStestlog ON QIStestlog.idevent = QISeventlog.id
            LEFT JOIN QIC.Vobra_new2.dbo.shortnote AS QISshortnote ON QISshortnote.id = QIStestlog.no
                AND QIStestlog.idvariable = '144'
            INNER JOIN QIC.Vobra_new2.dbo.variable AS QISvariable ON QISvariable.id = QIStestlog.idvariable
            LEFT JOIN QIC.Vobra_new2.dbo.vvarxproc AS vvp ON vvp.idvariable = QISvariable.id
                AND vvp.idprocess = QISP.idprocess
            LEFT JOIN QIC.Vobra_new2.dbo.attribute AS QISattribute ON QISattribute.id = vvp.idattribute
            LEFT JOIN QIC.Vobra_new2.dbo.grade AS QISgrade ON QISgrade.id = QISattribute.idgrade
            LEFT JOIN QIC.Vobra_new2.dbo.gradelevel AS gl ON gl.idgrade = QISattribute.idgrade
                AND gl.nlevel = QIStestlog.no
            WHERE QISbatchlog.nm NOT LIKE 'V%'
                AND QISP.dtstart > '2017-01-01'
                AND QISP.dtstart < '2017-01-19'
                AND QISP.idprocess IN (
                    '12'
                    ,'13'
                    ,'14'
                    ,'15'
                    ,'16'
                    ,'17'
                    ,'18'
                    ,'41'
                    )
                AND QIStestlog.idvariable IN (
                    '234'
                    ,'139'
                    ,'128'
                    )
            ) QISproduct ON g.artcode = QISproduct.nms
        WHERE g.bkjrcode > '2015'
            AND g.reknr IN (
                3000
                ,3010
                ,3020
                )
            AND g.aantal > 0
            AND g.warehouse IN (
                '1'
                ,'9'
                )
            AND g.datum >= '2017-01-01'
            AND g.oorsprong = 'R'
            AND g.kstplcode <> 'VPR'
        GROUP BY g.artcode
            ,i.Class_01
            ,i.IsStockItem


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. SQL सर्वर - जटिल गतिशील पिवट कॉलम

  2. अब स्थानीय SQL Server 2008 डेटाबेस से कनेक्ट नहीं हो सकता

  3. डालने पर डुप्लिकेट पंक्तियों को छोड़ें/अनदेखा करें

  4. DLL 'SqlServerSpatial.dll' लोड करने में असमर्थ

  5. मैं हाइबरनेट में बिगडेसिमल को कैसे मैप करूं ताकि मैं उसी पैमाने पर वापस आ सकूं जो मैंने रखा था?