I'm trying to fetch some info out of a table. To simplify, let's say the table (report_history) has 4 columns:
user_name, report_job_id, report_name, report_run_date.Each time a report is run in SQL, a record is written to this table noting the above info. What I am trying to do is pull from this table when the last time each distinct report was run and who ran it last.
OR, Other way to do this:
select user_name,report_run_date from report_history where report_run_date=(select max(report_run_date) from report_history)
Using this above query the result will be same , only the difference between these two queries is that the above query will give errors in case of same records in "report_run_date" column which will overcome by second below written query.
Powered by:

0 comments:
Post a Comment