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 |
|
mind_grapes
Yak Posting Veteran
71 Posts |
Posted - 2009-12-03 : 07:58:52
|
| Hi all, New to SQL so was hoping you could clarify if it is it possible to order by sub-squery? as i try this:select pss_store_code ,store_name ,pss_story_id ,st_titleFrom pgm_store_stories as ss inner join pgm_stories as st on ss.pss_story_id = st.st_id inner join stores as s on s.store_code = ss.pss_store_codeWhere pss_story_id > '7829' ( SELECT store_code FROM stores WHERE storeStatus = 'ON') ORDER BY ( SELECT st_title FROM pgm_stories )but get this error?(16382 row(s) affected)Msg 512, Level 16, State 1, Line 15Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.(0 row(s) affected) |
|
|
kbhere
Yak Posting Veteran
58 Posts |
Posted - 2009-12-03 : 08:04:13
|
| ORDER BY can have column names not the column values.. Your sub query returns multiple values in a column..So it is not possible..Balaji.K |
 |
|
|
rajdaksha
Aged Yak Warrior
595 Posts |
Posted - 2009-12-03 : 08:07:31
|
| HiDid you check the Syntax.-------------------------R... |
 |
|
|
mind_grapes
Yak Posting Veteran
71 Posts |
Posted - 2009-12-03 : 10:24:01
|
Hi, thank you for your reply.this may be a problem but i shall keep looking.Thank you.RegardsMGquote: Originally posted by kbhere ORDER BY can have column names not the column values.. Your sub query returns multiple values in a column..So it is not possible..Balaji.K
|
 |
|
|
Ifor
Aged Yak Warrior
700 Posts |
Posted - 2009-12-03 : 10:38:27
|
Maybe you want something like:SELECT pss_store_code ,store_name ,pss_story_id ,st_titleFROM pgm_store_stories AS ss JOIN pgm_stories AS st ON ss.pss_story_id = st.st_id JOIN stores AS s ON s.store_code = ss.pss_store_codeWHERE pss_story_id > '7829' AND S.storeStatus = 'ON'ORDER BY st_title |
 |
|
|
|
|
|
|
|