Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 A stupid problem

Author  Topic 

sangoku
Starting Member

19 Posts

Posted - 2009-09-04 : 13:02:27
I know i posted already one stupid question but i will do another. I am currently on a test where the professor is putting us some assignments and i am listening, not my turn yet, but it came to me, i cant remember how to put a limiter into a where limiter

like

select row, count row() as hell
group by row
where ???

and now i forgot what to put into it so i can select the value which has the highest row "hell" which is made up above

while earth still spining
live on, have fun
else
move to mars

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-09-04 : 13:56:31
select * from
(
select
col1,
col2,
row_count() over (partition by col2 order by col1 desc) as hell
from table
where col2 = 'yxz'
)dt
where hell = 1


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-09-04 : 14:00:54
webfred..did you mean

quote:
select * from
(
select
col1,
col2,
row_number() over (partition by col2 order by col1 desc) as hell
from table
where col2 = 'yxz'
)dt
where hell = 1

Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-09-04 : 14:04:57
quote:
Originally posted by vijayisonly

webfred..did you mean

quote:
select * from
(
select
col1,
col2,
row_number() over (partition by col2 order by col1 desc) as hell
from table
where col2 = 'yxz'
)dt
where hell = 1




Oh yes!
I'm an old man and this has been a hard week

GOOD CATCH!


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -