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.
Author |
Topic |
masond
Constraint Violating Yak Guru
447 Posts |
Posted - 2013-11-26 : 07:39:33
|
HI all I need some help Aim- I want to find out the earliest [First_Post_Date] for any parentdidMy query (See below) Produces the following results SELECT ParentID,[First_Post_Date],[FDMSAccountNo]FROM [FDMS].[dbo].[Dim_Outlet]where ParentID = '878595212886'Order by ParentID descReslts --> ParentID First_Post_Date FDMSAccountNo878595212886 NULL 878595212886878595212886 20080612 878595213884878595212886 20090507 878595214882Required results ParentID First_Post_Date 878595212886 20080612Looking forward to your help |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-11-26 : 07:42:10
|
[code]SELECT t.ParentID,[First_Post_Date],[FDMSAccountNo]FROM [FDMS].[dbo].[Dim_Outlet] tINNER JOIN (SELECT ParentID,MIN([First_Post_Date]) AS FirstDate FROM [FDMS].[dbo].[Dim_Outlet] GROUP BY ParentID )t1ON t1.ParentID = t.ParentIDAND t1.FirstDate = t.[First_Post_Date]where t.ParentID = '878595212886'Order by t.ParentID desc[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|