To find Second largest from Sub Query without using Row_number :
select * from payment
where payment_amt=(select min(payment_amt) from (select distinct top 2 payment_amt from payment order by payment_amt desc)temp)
select top 5 * from payment
order by payment_amt desc
select COUNT(*) as count from payment
Screen shot:
select * from payment
where payment_amt=(select min(payment_amt) from (select distinct top 2 payment_amt from payment order by payment_amt desc)temp)
select top 5 * from payment
order by payment_amt desc
select COUNT(*) as count from payment
Screen shot:
No comments:
Post a Comment