5 pts.
 Latest date SQL
Hi I am Trying to grab only the latest date from a uniquie stock number wich has mutiple dates? All i want to show is the lastest date against the stock number. Bear in mind that theese are comming from two different tables. Any Ideas

Software/Hardware used:
ASKED: August 7, 2008  9:33 AM
UPDATED: September 21, 2011  9:36 PM

Answer Wiki:
Try This Select S.StockNo,D. Date From StockTable S Join StockDate D On D.StockNo=S.StockNo Order By D.Date Desc -------------- I believe this is more along the lines of what the OP is looking for. <pre>SELECT StockId, Max(Date) FROM (SELECT StockId, max(Date) FROM FirstTable GROUP BY StockId UNION ALL SELECT StockId, max(Date) FROM SecondTable GROUP BY StockId) a GROUP BY StockId</pre>
Last Wiki Answer Submitted:  September 21, 2011  9:36 pm  by  Nvamsk   15 pts.
All Answer Wiki Contributors:  Nvamsk   15 pts. , Denny Cherry   64,520 pts. , Hotamar   15 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Check out my SQL Server blog “SQL Server with Mr Denny” for more SQL Server information.

 64,520 pts.