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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Subquery against same table

Author  Topic 

nietzky
Yak Posting Veteran

75 Posts

Posted - 2012-05-18 : 12:23:22
I am trying to populate in subquery all locations for MIRROR_DESTINATION_FILER in MIRROR_LOCATION
column

ex. LOCATION for Filer is different than location for MIRROR_DESTINATION_FILER. All locations are in S_VOL table, all filer names are in S_VOL table as well. I am having trouble to display these.

SELECT
Y.REGION
,Y.LOCATION
,Y.FILER
,Y.TIER
,(SELECT TOP 1 V1.LOCATION FROM S_VOL V1
LEFT JOIN (Select Distinct filer FROM S_VOL where LOCATION is not null ) V2
ON V1.MIRROR_DESTINATION_FILER = V2.FILER) AS MIRROR_LOCATION

FROM S_VOL Y

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2012-05-18 : 16:09:20
Can you supply sample data and expected outputs? If the data was in a format that could easily be used, an actual INSERT statement would be ideal, that would increase your chance of getting the support you need.

=================================================
There is a foolish corner in the brain of the wisest man. -Aristotle, philosopher (384-322 BCE)
Go to Top of Page
   

- Advertisement -