-1

需要帮助将以下 Oracle SQL 查询转换为 T-SQL 查询

SELECT rh.user_name, rh.report_name, rh.report_run_date
FROM report_history rh,
  (SELECT max(report_run_date) as maxdate, report_name
   FROM report_history
   GROUP BY report_name) maxresults
WHERE rh.report_name = maxresults.report_name
AND rh.report_run_date= maxresults.maxdate;
4

1 回答 1

2

尝试:

SELECT 
  rh.user_name, 
  rh.report_name, 
  rh.report_run_date

FROM 
  report_history rh

  INNER JOIN 
  (
     SELECT 
       max(report_run_date) as maxdate, 
       report_name
     FROM 
       report_history
     GROUP BY 
       report_name

  ) maxresults
  ON rh.report_name = maxresults.report_name
  AND rh.report_run_date= maxresults.maxdate;
于 2013-04-04T15:00:43.550 回答