how to fetch the last inserted (datetime) records for each category in database table
like:
select top 1 from table1, table2
where condition1 ...
and condition2 = case when (@var1 = null) then table2.condition2 else @var1
— for all categories if a specific one is not passed
order by Creation_Date
Any help is appreciated (esp. sample code). Thanks in advance.
I would use analytical functions