Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
huusker
Starting Member
3 Posts |
Posted - 2010-10-27 : 14:58:52
|
| Hi,I want one or more queries to print a lay-out for total hired parts per relationMy difficulty is more relations in tabel1 and more parts in tabel2See belowCan someone help me with this sql-code?In dutch:tabel1GEHUURDHOOFDhuurbonnr relatie________ _____gehdid1 rid10 gehdid2 rid15 gehdid3 rid10 gehdid4 rid18 tabel2GEHUURDRIJENhuurbonnr huurbonrijnr nr artcode aantal________ _________ __ ______ ______gehdid1 gehdregid1 nr0 artcode1 aantal5gehdid1 gehdregid2 nr1 artcode3 aantal1gehdid1 gehdregid3 nr2 artcode2 aantal12gehdid2 gehdregid4 nr0 artcode2 aantal19gehdid3 gehdregid5 nr0 artcode8 aantal21gehdid3 gehdregid6 nr1 artcode3 aantal1gehdid4 gehdregid7 nr0 artcode6 aantal6gehdid4 gehdregid8 nr1 artcode9 aantal2 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-10-27 : 15:24:22
|
| so wat should be your desired output in above case?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
huusker
Starting Member
3 Posts |
Posted - 2010-10-27 : 15:39:45
|
| Relation: rid10My desired output would be:articlecode totalhiredartcode1 5artcode2 12artcode3 2artcode8 21Relation rid15articlecode total hiredartcode2 19Relation rid18articlecode totalartcode6 6artcode9 2 |
 |
|
|
huusker
Starting Member
3 Posts |
Posted - 2010-10-28 : 01:40:20
|
| I've tried this sql-code:select table1.rid, table2.gehdregid, table2.artcode, table2.number-hired(in dutch'aantal')from table1inner join table2on table1.gehdid = table2.gehdidthe result of this is, I thinkrid10 gehdregid1 nr0 artcode1 aantal 5rid10 gehdregid2 nr1 artcode3 aantal 1rid10 gehdregid3 nr2 artcode2 aantal 12rid15 gehdregid4 nr0 artcode2 aantal 19rid10 gehdregid5 nr0 artcode8 aantal 21rid10 gehdregid6 nr1 artcode3 aantal 1rid18 gehdregid7 nr0 artcode6 aantal 6rid18 gehdregid8 nr1 artcode9 aantal 2my question is, how can I produce my desired output from the result of these select?thank you in advance |
 |
|
|
|
|
|