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 |
|
vguptais
Starting Member
8 Posts |
Posted - 2008-05-15 : 08:43:38
|
| Hi,Please help me in this. I have 3 tablesTable 1orderno Customer Value11083 12312 1254.23 11084 14521 12542.3511086 12548 1254.2011089 14586 1452.51Table 2orderno Textno11084 1542511084 1542111084 1542611086 1544111089 12548Table3Textno Text15425 the material is to be delivered by DHL15421 XXX special discount15426 price 52.32 net15441 XXX quantity discountNow i need the result as Orderno customer value TextOne order can have more than one text but only one or no text starts by XXX. if there is corresponding text starts by XXX i need that text in the resulting table if not it should just put ###.The problem is that I need all the records of the first table and no record should be duplicated.Please help.Vikrant Gupta |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-15 : 10:04:15
|
| [code]SELECT t1.Orderno,t1.customer,t1.value,coalesce(t3.Text,'###') as textFROM Table1 t1LEFT JOIN Table2 t2ON t2.orderno=t1.ordernoLEFT JOIN Table3 t3ON t3.Textno=t2.TextnoAND LEFT(t3.Text,3)='XXX'[/code] |
 |
|
|
dass05555
Yak Posting Veteran
55 Posts |
Posted - 2008-05-15 : 10:20:35
|
| Hi friend...chk the below query,i think it would satisfy u...if u not means tell me...select t1.Orderno ,t1.Customer,t1.value,coalesce(t3.Text,'--No Text--') fromtable1 t1 left join table2 t2 on t1.Orderno=t2.Orderno left outer join table3 t3 on t3.TextNo=t2.TextNocool..., |
 |
|
|
|
|
|