SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


complex joins retrive the echivalent results


complex joins retrive the echivalent results

Author
Message
Beniamin Joke
Beniamin Joke
Valued Member
Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)

Group: General Forum Members
Points: 60 Visits: 25
i want the result for which :
table GLMSO which has the
gmso colum 0003 and has both of bot
of KCTR's in GLCTA table

06 Eme3Prodcat2x
07 Eme4Prod
J Livingston SQL
J Livingston SQL
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12604 Visits: 37673
Beniamin Joke (7/14/2013)
i want the result for which :
table GLMSO which has the
gmso colum 0003 and has both of bot
of KCTR's in GLCTA table

06 Eme3Prodcat2x
07 Eme4Prod




SELECT DISTINCT
GLPSI.IDN AS GLMSO_GLPSI_IDN,
GLMSO.IDN AS GLMSO_IDN,
-- GLMSO.KMSO,
GLMSO.FAB,
GLMSO.DFINV,
GLMSO.DFINA,
GLCTA.KCTR,
GLCTA.DCAT
FROM GLMSO
INNER JOIN GLARA ON GLARA.IDN = GLMSO.IDN
AND GLARA.KARA = GLMSO.KARA
INNER JOIN GLPSI ON GLPSI.IDN = GLARA.IDN
AND GLPSI.KPSI = GLARA.KPSI
INNER JOIN GLCMS ON GLCMS.IDN = GLMSO.IDN
AND GLCMS.KMSO = GLMSO.KMSO
INNER JOIN GLCVA ON GLCMS.IDN = GLCVA.IDN
AND GLCMS.KCVA = GLCVA.KCVA
INNER JOIN GLCTR ON GLCVA.IDN = GLCTR.IDN
AND GLCVA.KCTR = GLCTR.KCTR
INNER JOIN GLCTA ON GLMSO.IDN = GLCTA.IDN
AND GLMSO.KARA = GLCTA.KARA
WHERE ( GLPSI.IDN = '0099' )
AND ( GLMSO.FAB = 'A' )


SELECT DISTINCT
GLPSI.IDN AS GLMSO_GLPSI_IDN,
GLMSO.IDN AS GLMSO_IDN,
GLMSO.KMSO,
GLMSO.FAB,
GLMSO.DFINV,
GLMSO.DFINA,
GLCTA.KCTR,
GLCTA.DCAT
FROM GLMSO
INNER JOIN GLARA ON GLARA.IDN = GLMSO.IDN
AND GLARA.KARA = GLMSO.KARA
INNER JOIN GLPSI ON GLPSI.IDN = GLARA.IDN
AND GLPSI.KPSI = GLARA.KPSI
INNER JOIN GLCMS ON GLCMS.IDN = GLMSO.IDN
AND GLCMS.KMSO = GLMSO.KMSO
INNER JOIN GLCVA ON GLCMS.IDN = GLCVA.IDN
AND GLCMS.KCVA = GLCVA.KCVA
INNER JOIN GLCTR ON GLCVA.IDN = GLCTR.IDN
AND GLCVA.KCTR = GLCTR.KCTR
INNER JOIN GLCTA ON GLMSO.IDN = GLCTA.IDN
AND GLMSO.KARA = GLCTA.KARA
WHERE ( GLPSI.IDN = '0099' )
AND ( GLMSO.FAB = 'A' )
AND ( GLMSO.KMSO = '0003' )




________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day

Beniamin Joke
Beniamin Joke
Valued Member
Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)

Group: General Forum Members
Points: 60 Visits: 25
Hi
the expected result should be where the gmso colums is equal to 003 from GLMSO table and which have in table GLCTA the column KCTR equal to 01 and 02
J Livingston SQL
J Livingston SQL
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12604 Visits: 37673
Beniamin Joke (7/14/2013)
Hi
the expected result should be where the gmso colums is equal to 003 from GLMSO table and which have in table GLCTA the column KCTR equal to 01 and 02


I don't see a "gmso" column in table GLMSO??

your setup code

create table GLMSO
(
IDN char(4),
KMSO char(4),
KMSOP char(6) null,
KARA char(2),
COD varchar(30) null,
NOM varchar (30) null,
DNAS char(8),
DINIV char(8),
DFINV char(8),
DFINA char(8),
FAB char(1),
UPS char(6),
UPD char(12),
KTDM char(2) not null

________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day

Beniamin Joke
Beniamin Joke
Valued Member
Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)

Group: General Forum Members
Points: 60 Visits: 25
sorry it's kmso the column and not gmso ,i am a little sleepy
J Livingston SQL
J Livingston SQL
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12604 Visits: 37673
Beniamin Joke (7/14/2013)
sorry it's kmso the column and not gmso ,i am a little sleepy


ok...sleep well

try running the "simplified" queries I posted earlier, when you are able.

________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search