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 |
|
paramu
Posting Yak Master
151 Posts |
Posted - 2010-01-12 : 03:28:36
|
| Hi,I have a update query, But need with Order by Clause.I cannot identify the error....update sales_master set un_rate = (select qtnmaster.un_rate where qtnmaster.itemcode=sales_master.itemcode order by (0+qtnmaster.Qtnno))Thanks For The Ideas...Paramu @ PARANTHAMAN |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-01-12 : 03:30:53
|
| [code]update sset s.un_rate=q.un_ratefrom sales_master scross apply (select top 1 un_rate from qtnmaster where itemcode=sales_master.itemcode order by (0+Qtnno))q[/code] |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-01-12 : 04:09:22
|
| "update sales_master set un_rate = (select qtnmaster.un_rate where qtnmaster.itemcode=sales_master.itemcode order by (0+qtnmaster.Qtnno))"Isn't that trying to set each row in [sales_master] to every row in [un_rate] just to try to get the "last" row?Could you change the Sub Select to SELECT TOP 1 and change the ORDER BY to be DESCending? |
 |
|
|
paramu
Posting Yak Master
151 Posts |
Posted - 2010-01-12 : 06:22:15
|
| Great.!!!Thanks For The Wonderful Tips !!! [Both]After adding DESC to Visakh's ideas, I found the required O/P.Thanks Again..To Both Ideas.!!!Paramu @ PARANTHAMAN |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-01-12 : 06:49:05
|
welcome |
 |
|
|
|
|
|