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
 find datemax from result of join query

Author  Topic 

spinningtop
Starting Member

29 Posts

Posted - 2010-11-23 : 07:05:46


Hi

I have an inner join query as below where I want to run a groupby datemax query on the results of it where [table1].[columnb] is a datetime column. In Access I would save the join query and then run the datemax query on the join query. I'm not sure how I would run this in SQL server to bet the same results though? Any ideas?


SELECT [table1].[columnA], [table1].[columnb], [table2].[columnA], [table2].[columnB],
FROM table1
INNER JOIN [table2] ON [table1].[columnC] = [table2].[columnC]
WHERE [table1].[columnA] = 'myrecords'



webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-11-23 : 07:29:01
To use the resultset of your posted query like a table you can put parentheses around and give it an alias name.
Then you can do what you want with that derived table:

selct * from
(here_comes_your_query) as dt
where ...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-11-24 : 09:32:29
also once you apply group by on a column you need to apply aggregate functions on other column if you want to return them.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -