1 Reply Latest reply: Oct 28, 2016 11:36 AM by Sunny Talwar RSS

    SQL statement in Qlik

    Santiago Sánchez

      Hi,

       

      I need to performe this sql statement in qlik with the load script. I mean I have the tables stores in qvds and i need to get the same result of this sql statement with load in Qlik.

       

      SQL SELECT DISTINCT TRA.Idetra, TRA.FechaTecleo, CLA.Nombre, TRA.ImpTras

              FROM GTR_Traspasos TRA

                      LEFT JOIN GTR_Tras_Clasificacion CLA ON TRA.IdClasificacion = CLA.Id

                      LEFT JOIN GTR_EstadoFinal ESTFIN ON TRA.IdEstadoFinal = ESTFIN.Id_Estado_Final

                      LEFT JOIN GTR_MS_Estados EST ON ESTFIN.IdEstado = EST.IdEstado

                      LEFT JOIN GTR_MS_TipInfo TIPINF ON ESTFIN.Id_TipInfo = ESTFIN.Id_TipInfo

              WHERE TRA.FlagEstado <>  0 AND ESTFIN.IdEstado = 1 AND TIPINF.Id_TipInfo = 4

                      AND TRA.Fecha_Fichero = (SELECT MAX(TRA2.Fecha_Fichero) FROM GTR_Traspasos TRA2 WHERE TRA.Idetra = TRA2.Idetra)

              ORDER BY CLA.Nombre, TRA.FechaTecleo;

       

      The tables are store in qvds but i don´t know how to structure the load

        • Re: SQL statement in Qlik
          Sunny Talwar

          May be like this:

           

          Table:

          SQL SELECT DISTINCT TRA.Idetra, TRA.FechaTecleo, CLA.Nombre, TRA.ImpTras

                  FROM GTR_Traspasos TRA

                          LEFT JOIN GTR_Tras_Clasificacion CLA ON TRA.IdClasificacion = CLA.Id

                          LEFT JOIN GTR_EstadoFinal ESTFIN ON TRA.IdEstadoFinal = ESTFIN.Id_Estado_Final

                          LEFT JOIN GTR_MS_Estados EST ON ESTFIN.IdEstado = EST.IdEstado

                          LEFT JOIN GTR_MS_TipInfo TIPINF ON ESTFIN.Id_TipInfo = ESTFIN.Id_TipInfo

                  WHERE TRA.FlagEstado <>  0 AND ESTFIN.IdEstado = 1 AND TIPINF.Id_TipInfo = 4

                          AND TRA.Fecha_Fichero = (SELECT MAX(TRA2.Fecha_Fichero) FROM GTR_Traspasos TRA2 WHERE TRA.Idetra = TRA2.Idetra)

                  ORDER BY CLA.Nombre, TRA.FechaTecleo;

           

          STORE Table into YourPath\QvdName.qvd (qvd);