I am trying to select many rows, but only the MAX rows of each
distinct lead_seq. I don't want to actually select the MAX rows, just
make it a condition.
This is what I have:
declare @in_report_date datetime
SET @in_report_date = '07/06/2003'
select lah.lead_seq
FROM lead_action_his tory lah
RIGHT outer join lead_master lm on lm.lead_seq = lah.lead_seq
WHERE lah.lead_action _date = (select max(lah.lead_ac tion_date) from
lead_action_his tory)
GROUP BY lah.lead_seq, lah.lead_action _date
I've tried implementing a HAVING with no luck. Is there a simple
solution?
Any ideas would be much appreciated.
Thanks!
Mike
distinct lead_seq. I don't want to actually select the MAX rows, just
make it a condition.
This is what I have:
declare @in_report_date datetime
SET @in_report_date = '07/06/2003'
select lah.lead_seq
FROM lead_action_his tory lah
RIGHT outer join lead_master lm on lm.lead_seq = lah.lead_seq
WHERE lah.lead_action _date = (select max(lah.lead_ac tion_date) from
lead_action_his tory)
GROUP BY lah.lead_seq, lah.lead_action _date
I've tried implementing a HAVING with no luck. Is there a simple
solution?
Any ideas would be much appreciated.
Thanks!
Mike
Comment