Buenas tardes compañeros, necesito hacer la union de estas 2 tablas OCRD y OCQG
OCRD datos maestros socios negocio
OCQG propiedades del socio de negocio
Para ver el CardCode, CardName (OCRD ), GroupName (OCQG)
E intentado varias cosas pero no le doy con el chiste, espero me puedan ayudar muchas gracias.
Finalmente tuve que hacerlo de esta manera, tomando las propiedades de OCRD y comparándolos con los groupcode de OCQG uno a uno, si alguien encuentra una forma mas simplificada de hacerlo bienvenida sea, de momento yo propongo esta. Saludos .
SELECT DISTINCT T0."CardCode", T0."CardName", T1."GroupName" FROM OCRD T0 LEFT JOIN OCQG T1 ON (CASE WHEN T0."QryGroup1" = 'Y' THEN 1 WHEN (T0."QryGroup2" = 'Y') THEN 2 WHEN (T0."QryGroup3" = 'Y') THEN 3 WHEN (T0."QryGroup4" = 'Y') THEN 4 WHEN (T0."QryGroup5" = 'Y') THEN 5 WHEN (T0."QryGroup6" = 'Y') THEN 6 WHEN (T0."QryGroup7" = 'Y') THEN 7 WHEN (T0."QryGroup8" = 'Y') THEN 8 WHEN (T0."QryGroup9" = 'Y') THEN 9 WHEN (T0."QryGroup10" = 'Y') THEN 10 WHEN (T0."QryGroup11" = 'Y') THEN 11 WHEN (T0."QryGroup12" = 'Y') THEN 12 WHEN (T0."QryGroup13" = 'Y') THEN 13 WHEN (T0."QryGroup14" = 'Y') THEN 14 WHEN (T0."QryGroup15" = 'Y') THEN 15 WHEN (T0."QryGroup16" = 'Y') THEN 16 WHEN (T0."QryGroup17" = 'Y') THEN 17 WHEN (T0."QryGroup18" = 'Y') THEN 18 WHEN (T0."QryGroup19" = 'Y') THEN 19 WHEN (T0."QryGroup20" = 'Y') THEN 20 WHEN (T0."QryGroup21" = 'Y') THEN 21 WHEN (T0."QryGroup22" = 'Y') THEN 22 WHEN (T0."QryGroup23" = 'Y') THEN 23 WHEN (T0."QryGroup24" = 'Y') THEN 24 WHEN (T0."QryGroup25" = 'Y') THEN 25 WHEN (T0."QryGroup26" = 'Y') THEN 26 WHEN (T0."QryGroup27" = 'Y') THEN 27 WHEN (T0."QryGroup28" = 'Y') THEN 28 WHEN (T0."QryGroup29" = 'Y') THEN 29 WHEN (T0."QryGroup30" = 'Y') THEN 30 WHEN (T0."QryGroup31" = 'Y') THEN 31 WHEN (T0."QryGroup32" = 'Y') THEN 32 WHEN (T0."QryGroup33" = 'Y') THEN 33 WHEN (T0."QryGroup34" = 'Y') THEN 34 WHEN (T0."QryGroup35" = 'Y') THEN 35 WHEN (T0."QryGroup36" = 'Y') THEN 36 WHEN (T0."QryGroup37" = 'Y') THEN 37 WHEN (T0."QryGroup38" = 'Y') THEN 38 WHEN (T0."QryGroup39" = 'Y') THEN 39 WHEN (T0."QryGroup40" = 'Y') THEN 40 WHEN (T0."QryGroup41" = 'Y') THEN 41 WHEN (T0."QryGroup42" = 'Y') THEN 42 WHEN (T0."QryGroup43" = 'Y') THEN 43 WHEN (T0."QryGroup44" = 'Y') THEN 44 WHEN (T0."QryGroup45" = 'Y') THEN 45 WHEN (T0."QryGroup46" = 'Y') THEN 46 WHEN (T0."QryGroup47" = 'Y') THEN 47 WHEN (T0."QryGroup48" = 'Y') THEN 48 WHEN (T0."QryGroup49" = 'Y') THEN 49 WHEN (T0."QryGroup50" = 'Y') THEN 50 WHEN (T0."QryGroup51" = 'Y') THEN 51 WHEN (T0."QryGroup52" = 'Y') THEN 52 WHEN (T0."QryGroup53" = 'Y') THEN 53 WHEN (T0."QryGroup54" = 'Y') THEN 54 WHEN (T0."QryGroup55" = 'Y') THEN 55 WHEN (T0."QryGroup56" = 'Y') THEN 56 WHEN (T0."QryGroup57" = 'Y') THEN 57 WHEN (T0."QryGroup58" = 'Y') THEN 58 WHEN (T0."QryGroup59" = 'Y') THEN 59 WHEN (T0."QryGroup60" = 'Y') THEN 60 WHEN (T0."QryGroup61" = 'Y') THEN 61 WHEN (T0."QryGroup62" = 'Y') THEN 62 WHEN (T0."QryGroup63" = 'Y') THEN 63 WHEN (T0."QryGroup64" = 'Y') THEN 64 END)= T1."GroupCode" WHERE T0."QryGroup1" = 'Y' OR "QryGroup2" = 'Y' OR "QryGroup3" = 'Y' OR "QryGroup4" = 'Y' OR "QryGroup5" = 'Y' OR "QryGroup6" = 'Y' OR "QryGroup7" = 'Y' OR "QryGroup8" = 'Y' OR "QryGroup9" = 'Y' OR "QryGroup10" = 'Y' OR "QryGroup11" = 'Y' OR "QryGroup12" = 'Y' OR "QryGroup13" = 'Y' OR "QryGroup14" = 'Y' OR "QryGroup15" = 'Y' OR "QryGroup16" = 'Y' OR "QryGroup17" = 'Y' OR "QryGroup18" = 'Y' OR "QryGroup19" = 'Y' OR "QryGroup20" = 'Y' OR "QryGroup21" = 'Y' OR "QryGroup22" = 'Y' OR "QryGroup23" = 'Y' OR "QryGroup24" = 'Y' OR "QryGroup25" = 'Y' OR "QryGroup26" = 'Y' OR "QryGroup27" = 'Y' OR "QryGroup28" = 'Y' OR "QryGroup29" = 'Y' OR "QryGroup30" = 'Y' OR "QryGroup31" = 'Y' OR "QryGroup32" = 'Y' OR "QryGroup33" = 'Y' OR "QryGroup34" = 'Y' OR "QryGroup35" = 'Y' OR "QryGroup36" = 'Y' OR "QryGroup37" = 'Y' OR "QryGroup38" = 'Y' OR "QryGroup39" = 'Y' OR "QryGroup40" = 'Y' OR "QryGroup41" = 'Y' OR "QryGroup42" = 'Y' OR "QryGroup43" = 'Y' OR "QryGroup44" = 'Y' OR "QryGroup45" = 'Y' OR "QryGroup46" = 'Y' OR "QryGroup47" = 'Y' OR "QryGroup48" = 'Y' OR "QryGroup49" = 'Y' OR "QryGroup50" = 'Y' OR "QryGroup51" = 'Y' OR "QryGroup52" = 'Y' OR "QryGroup53" = 'Y' OR "QryGroup54" = 'Y' OR "QryGroup55" = 'Y' OR "QryGroup56" = 'Y' OR "QryGroup57" = 'Y' OR "QryGroup58" = 'Y' OR "QryGroup59" = 'Y' OR "QryGroup60" = 'Y' OR "QryGroup61" = 'Y' OR "QryGroup62" = 'Y' OR "QryGroup63" = 'Y' OR "QryGroup64" = 'Y' ORDER BY T1."GroupName" ASC, T0."CardCode" ASC
Hola Camilo,
No hay forma de unirse a las tablas OCRD y OCQG
Espero que esta respuesta a una pregunta similar pueda ayudarte.
Saludos,
Johan
Gracias Johan, finalmente lo hice de una forma un poco similar a la que me compartiste; les comparti el código.