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 2005 Forums
 Transact-SQL (2005)
 correlated subquery help!

Author  Topic 

breaker098
Starting Member

2 Posts

Posted - 2008-03-24 : 15:26:44
I'm trying to take the 2nd block of SQL and implement it into the first so that I can have a correlated subquery. Can anyone help me with formatting this or at lease getting closer? I'm lost!

select * from st_Meta_Field MF
INNER JOIN st_field F ON MF.Field_ID = F.Field_ID
where F.Table_ID = 5 AND (F.Field_Name = 'XXX' OR F.Field_Name = 'YYY')
AND F.Record_State = 1 AND MF.Record_State = 1

select max(display_row),subset_value
from st_Meta_Field where table_id = 5 AND Display_Row < 500
group by Subset_Value

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2008-03-24 : 15:52:40
What did you want to corellate it on?

=======================================
Do something for somebody every day for which you do not get paid. -Albert Schweitzer, philosopher, physician, musician, Nobel laureate (1875-1965)
Go to Top of Page

breaker098
Starting Member

2 Posts

Posted - 2008-03-24 : 16:04:57
select max(display_row),subset_value
from st_Meta_Field where table_id = 5 AND Display_Row < 500
group by Subset_Value

This SQL chunk returns the max display row and subset

select * from st_Meta_Field MF
INNER JOIN st_field F ON MF.Field_ID = F.Field_ID
where F.Table_ID = 5 AND (F.Field_Name = 'XXX' OR F.Field_Name = 'YYY')
AND F.Record_State = 1 AND MF.Record_State = 1

This SQL chunk simply joins the two tables based and returns the data for the two fields.

Ultimately what I would like to do is update the display row for these two fields based on the current max display row is already at.
Go to Top of Page
   

- Advertisement -