
August 9th, 2012, 11:48 AM
|
|
Contributing User
|
|
Join Date: Oct 2003
Location: Germany
|
|
Code:
select type1,
type2,
quantity,
date_ordered,
from (
select type1,
type2,
quantity,
date_ordered,
row_number() over (partition by type1, type2 order by date_ordered desc) as rn
from the_unknown_table
) t
where rn = 1
__________________
I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags.
http://forums.devshed.com/misc.php?do=bbcode#code
Tips on how to ask better questions:
http://tkyte.blogspot.de/2005/06/how-to-ask-questions.html
http://wiki.postgresql.org/wiki/SlowQueryQuestions
http://catb.org/esr/faqs/smart-questions.html
|