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 |
|
Sep410
Posting Yak Master
117 Posts |
Posted - 2008-06-05 : 16:05:09
|
| Hi,I know it is simple query but I am confused.I need to make a query from 3 tables in the same database. There are no relations between these tables.Here is result I need.KE LE JE15 775.5 39818 192.23 399Please help me.Sep |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-06-05 : 16:18:49
|
| If there is no relation between the three tables, then you can't join them together. You could union them together though.SELECT A FROM Table1UNOIN ALLSELECT B FROM Table2UNION ALLSELECT C FROM Table3I suppose you could pivot the data by using the above as a derived table.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
 |
|
|
Sep410
Posting Yak Master
117 Posts |
Posted - 2008-06-05 : 16:25:06
|
| Thank you for reply but I need to have KE LE JE15 775.5 39818 192.23 399Union All will return :Ke1518775.5192.23398399It is not what I need.Please help me.Sep |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-06-05 : 16:29:56
|
| So you need to pivot it as mentioned in my first reply. Check out PIVOT in SQL Server Books Online. I don't have time to come up with a solution for you right now, so I provided the keywords you'll need.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
 |
|
|
Sep410
Posting Yak Master
117 Posts |
Posted - 2008-06-05 : 18:30:39
|
| Ok,ThanksSep |
 |
|
|
|
|
|