Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Finding Earliest Date
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Constraint Violating Yak Guru

447 Posts

Posted - 11/26/2013 :  07:39:33  Show Profile  Reply with Quote
HI all

I need some help

Aim- I want to find out the earliest [First_Post_Date] for any parentdid

My query (See below)
Produces the following results
FROM [FDMS].[dbo].[Dim_Outlet]
where ParentID = '878595212886'
Order by ParentID desc
Reslts -->
ParentID First_Post_Date FDMSAccountNo
878595212886 NULL 878595212886
878595212886 20080612 878595213884
878595212886 20090507 878595214882

Required results
ParentID First_Post_Date
878595212886 20080612

Looking forward to your help

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 11/26/2013 :  07:42:10  Show Profile  Reply with Quote

FROM [FDMS].[dbo].[Dim_Outlet] t
INNER JOIN (SELECT ParentID,MIN([First_Post_Date]) AS FirstDate
            FROM [FDMS].[dbo].[Dim_Outlet]
            GROUP BY ParentID
ON t1.ParentID = t.ParentID
AND t1.FirstDate = t.[First_Post_Date]
where t.ParentID = '878595212886'
Order by t.ParentID desc

SQL Server MVP

Edited by - visakh16 on 11/26/2013 07:42:48
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000