1
COMPANY PROD    ID  DATE            NAME        REQD_DATE
XYZ 12345   AAA111  7/1/2011    PETER   
XYZ 12345   PPP222  7/1/2002    JOHN    
MNS 67890   ZZZ999  9/1/2005    STEVE   
MNS 67890   DDD555  9/1/2012    MARTIN  

With reference to this above table say '#temp', Whenever COMPANY AND PROD are same, I want to get the min of date {min(DATE)} into column 'REQD_DATE'

Can someone please help me out here?

Thanks in advance!

Marc B
  • 356,200
  • 43
  • 426
  • 500
  • you'd use a group-by on the company+prod fields, and min() on the reqd_date. But you'll have to figure that out on your own. We're not here to do your job for you - you have to show you at least tried this on your own. – Marc B Oct 15 '12 at 15:32
  • I have tried it in many ways but failed! 1) I tried using where clause.. WHERE a.DATE IN (SELECT MIN(DATE) FROM #temp WHERE DATE = a.DATE) 2) I also tried using an update statement update #temp set DATE = case when DATE < (select top 1 min(DATE) from #temp) then DATE else '' end None of these worked! Let me try with your method! Thanks though! – user1747543 Oct 15 '12 at 15:46

0 Answers0