Hello, everyone!
Does anyone know how I can pull additional field in a database when
the max() of one field is pulled. For example:
================================================== ===
SELECT TOP 200 foreign_id, MAX(recordcreateddatetime) AS
max_recordcreateddatetime
FROM table1
GROUP BY foreign_id
================================================== ===
Here I am trying to pull the records that have the latest date for
each foreign_id. The result set above will pull foreign_id and
max_recordcreateddatetime but I needed to also have it display one
more field, current_status like this:
================================================== ===
SELECT TOP 200 foreign_id, MAX(recordcreateddatetime) AS
max_recordcreateddatetime, current_status
FROM table1
GROUP BY foreign_id
================================================== ===
The problem however is that SQL wants me to add this field to GROUP BY
or use an aggregate function with it and I don't want any aggregate
function processing - I just want current_status to show up there for
me to see. How do I do this?
Thank you for any input in advance!
Roumen.