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
 How would I just pull the last 6 in a column?

Author  Topic 

Matt1856
Starting Member

1 Post

Posted - 2009-08-12 : 12:08:50
Does anyone know how I would just pull the last 6 rows in a column of 1000 and average just those 6 in Showcase Query?

Thanks

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-08-12 : 12:16:29
You can select top 6 in descending order.


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

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-08-12 : 12:55:51
[code]
SELECT AVG(col1) as avg_col1 FROM
(
SELECT TOP 6 col1 FROM table
ORDER BY Whatever DESC
)dt
[/code]


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

- Advertisement -