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
 General SQL Server Forums
 New to SQL Server Programming
 Selecting a specific record from query results

Author  Topic 

wleonard
Starting Member

30 Posts

Posted - 2011-02-24 : 14:24:09
I am trying to select a specific record from an executed query. My logic would go something like this:

SELECT blah blah from (query) where blah blah = blah blah

But this logic does not execute properly. Here is my query:

SELECT DISTINCT b.uhc_description, c.uhc_description
FROM tblUserhierarchychoice a, tblUserhierarchychoice b, tblUserhierarchychoice c
where c.uhl_level = 'B' and a.uhl_level = 'A' and
b.uhl_level = 'M' and a.udh_parent_level = b.uhl_level and a.uhc_parent_code = b.uhc_code
and c.udh_parent_level = a.uhl_level and c.uhc_parent_code = a.uhc_code
order by b.uhc_description

Please give some feedback when possible.

Will Leonard

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-02-24 : 14:55:59
Here's a different version of the same:


SELECT DISTINCT b.uhc_description, c.uhc_description
FROM tblUserhierarchychoice a
inner join tblUserhierarchychoice b on a.udh_parent_level = b.uhl_level and a.uhc_parent_code = b.uhc_code
inner join tblUserhierarchychoice c on c.udh_parent_level = a.uhl_level and c.uhc_parent_code = a.uhc_code
where c.uhl_level = 'B'
and a.uhl_level = 'A'
and b.uhl_level = 'M'
order by b.uhc_description
Go to Top of Page
   

- Advertisement -