Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

using outer query column name in subquery while doing order by Expand / Collapse
Author
Message
Posted Friday, January 29, 2010 5:17 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Wednesday, April 18, 2012 4:04 AM
Points: 76, Visits: 36
using outer query column name in subquery while doing order by caluse

ex: Select name,id,school from <Student>
where id in
(select top 5 id from <Somtable> order by school)

school name is not present in <Sometable>

will it work...i experinced this type situation.
it has worked.
can any one give reasons..how it is working..?
Post #855974
Posted Friday, January 29, 2010 8:17 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Wednesday, May 15, 2013 12:31 PM
Points: 580, Visits: 814
You're basically doing an inner join between <Student> and <School> on ID columns. Are IDs unique across these two tables?


_____________________________________________________________________
- Nate

@nate_hughes
Post #856122
Posted Saturday, January 30, 2010 5:07 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Wednesday, April 18, 2012 4:04 AM
Points: 76, Visits: 36
Some ids of student table will present in school table...i am not dding inner join..if i go for inner join..will get all rows which were common based on id
Post #856628
Posted Saturday, January 30, 2010 5:14 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 3:56 AM
Points: 37,734, Visits: 30,003
Please post table definitions, sample data and desired output. Read this to see the best way to post this to get quick responses.
http://www.sqlservercentral.com/articles/Best+Practices/61537/



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #856632
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse