How can i join 3 tables and calculate the data in 3 tables.

%3CLINGO-SUB%20id%3D%22lingo-sub-1119167%22%20slang%3D%22en-US%22%3EHow%20can%20i%20join%203%20tables%20and%20calculate%20the%20data%20in%203%20tables.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1119167%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%203%20tables%20sales%2C%20production%20and%20consumption%20with%20which%20i%20have%2020%20orders%20for%20item%20b%20and%20the%20other%202%20tables%20have%20the%20raw%20materials%20to%20make%20the%20item%20b.%20The%20production%20and%20consumption%20table%20gives%20the%20qty%20for%20preparing%20one%20item%20b.%20So%20i%20have%20to%20calculate%20qty%20for%2020%20such%20item%20b.%20So%20in%20the%20output%20i%20need%20item%20name%20and%20the%20quantity%20for%20each%20item.%20so%20can%20anyone%20solve%20this%20issue.%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F166223i5ADDB03847FA6678%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Untitled.png%22%20title%3D%22Untitled.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1138441%22%20slang%3D%22en-US%22%3ERe%3A%20How%20can%20i%20join%203%20tables%20and%20calculate%20the%20data%20in%203%20tables.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1138441%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F526450%22%20target%3D%22_blank%22%3E%40Varghese123%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECould%20you%20please%20attach%20your%20SQL%20statement%20which%20made%20your%20own%20first%3F%20It%E2%80%99s%20more%20efficient%20to%20give%20you%20a%20hand%20against%20your%20script.%20If%20you%20have%20no%20idea%2C%20try%20to%20fulfill%20the%20temple%20below%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-java%22%3E%3CCODE%3ESelect%20%3CTABLE1%3E.%3CFIELD1%3E%2C...%0AFrom%20%3CTABLE1%3E%20inner%2Fright%2Fleft%20join%20%3CTABLE2%3E%20on%20%3CTABLE1.FOREIGN%20key1%3D%22%22%3E%20%3D%20%3CTABLE2.FOREIGN%20key1%3D%22%22%3E%20....%0Ainner%2Fright%2Fleft%20join....%0AWhere....%3C%2FTABLE2.FOREIGN%3E%3C%2FTABLE1.FOREIGN%3E%3C%2FTABLE2%3E%3C%2FTABLE1%3E%3C%2FFIELD1%3E%3C%2FTABLE1%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%2C%26nbsp%3B%3C%2FP%3E%3CP%3ESten%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

Hi, 

I have 3 tables sales, production and consumption with which i have 20 orders for item b and the other 2 tables have the raw materials to make the item b. The production and consumption table gives the qty for preparing one item b. So i have to calculate qty for 20 such item b. So in the output i need item name and the quantity for each item. so can anyone solve this issue.Untitled.png

1 Reply

Hi @Varghese123 ,

 

Could you please attach your SQL statement which made your own first? It’s more efficient to give you a hand against your script. If you have no idea, try to fulfill the temple below:

Select <table1>.<field1>,...
From <table1> inner/right/left join <table2> on <table1.foreign key1> = <table2.foreign key1> ....
inner/right/left join....
Where....

 

Regards, 

Sten