CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge -> Programming

 Most Recent Date

Print topic Send  topic

Author Message
Ludgero

Posts: 1
Posted: 08/08/2006, 3:59 PM

I have a database that has information on status of employee's. I'm trying to write a SQL statement that will select only information from the Most recent date. I can get this to work with a simple script, but when I attempt to add the rest of the information in, Trouble!

SELECT Max(qryOpen_Action.Rec_Date) AS aRec_Date, qryOpen_Action.StaffID
FROM qryOpen_Action
GROUP BY qryOpen_Action.StaffID;

This script only uses two fields currently, but I need quite a few more. other fields I want to integrate are, Action, Department, Position, ROP. I do NOT want all the fields grouped tho. I can get it to work by MAX'n the Rec_Date & having all the other fields grouped, but that is not how I need the data. I just want the most Recent Date for the different StaffID's & the other accompanying data! Is there a way to avoid grouping everything together?

Thanks MUCH!
View profile  Send private message
Abs
Posted: 08/18/2006, 2:26 AM

Hi There,

When you say recent, do you mean all the records entered on the most recent date? If so, this may work for you:

SELECT * FROM qryOpen_Action  
WHERE DATEDIFF(DAY,GETDATE(),Rec_Date) = (SELECT MIN(DATEDIFF(DAY,GETDATE(), Rec_Date)) FROM qryOpen_Action)

This does not require grouping of columns.

Hope this helps.


Abs

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.