Skip to Content
author's profile photo Former Member
Former Member

Unir dos resultados de querys

Buenas tardes mi duda es algo simple, como puedo unir dos resultados de consultas tengo la consulta :

SELECT Total=(Price*Quantity), T1.[ItmsGrpCod], t0.*

FROM IGE1 T0

INNER JOIN OITM T1 ON T0.[ItemCode] = T1.[ItemCode]

WHERE T1.[ItmsGrpCod] = 162 OR T1.[ItmsGrpCod] =164 OR T1.[ItmsGrpCod] = 167

Y la consulta

SELECT T1.[ResType],T0.*

FROM IGE1 T0

INNER JOIN ORSC T1 ON T0.[ItemCode] = T1.[VisResCode]

Como puedo los dos resultados unirlos para que tuviera la columna ResType, ItmsGrpCod, Total agregadas a todas las columnas de la tabla IGE1 con los datos de los resultados respectivamente

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Apr 06, 2016 at 06:52 PM

    Prueba esto

    SELECT (Price*Quantity) Total, T1.[ItmsGrpCod] GrpArt,T2.[ResType],T0.*

    FROM IGE1 T0

    INNER JOIN OITM T1 ON T0.[ItemCode] = T1.[ItemCode]

    INNER JOIN ORSC T2 ON T0.[ItemCode] = T2.[VisResCode]

    WHERE T1.[ItmsGrpCod] = 162 OR T1.[ItmsGrpCod] =164 OR T1.[ItmsGrpCod] = 167

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Gerardo Mendez

      Una duda si a lo generado con la union all quiero agregarle una columna de otra tabla? algo asi

      SELECT Total=(Price*Quantity), CodGrupo = CAST(T1.[ResType] AS char) ,T0.BaseEntry
      FROM IGE1 T0
      INNER JOIN ORSC T1 ON T0.[ItemCode] = T1.[VisResCode]

      Union All

      SELECT Total=(Price*Quantity),CodGrupo = CAST(T1.[ItmsGrpCod] AS char),T0.BaseEntry
      FROM IGE1 T0
      INNER JOIN OITM T1 ON T0.[ItemCode] = T1.[ItemCode]
      WHERE T1.[ItmsGrpCod] = 162 OR T1.[ItmsGrpCod] =164 OR T1.[ItmsGrpCod] = 167

      Pero quiero agregarle una columna de @presupuesto_det, la columna DocEntry y presupuesto_det se liga con IGE1 por el campo IGE1.BaseEntry = @presupuesto_det.U_OF, con otra union no creo se pueda como podria hacerse la union ya de 4 tablas practicamente

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.