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: Friday, September 12, 2014 10:55 AM
Points: 80, Visits: 49
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


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Thursday, November 20, 2014 2:30 PM
Points: 628, Visits: 870
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: Friday, September 12, 2014 10:55 AM
Points: 80, Visits: 49
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-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 8:36 AM
Points: 40,615, Visits: 37,080
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