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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to find avg of last N-1 records in sql?

Author  Topic 

janardhana
Starting Member

4 Posts

Posted - 2008-06-24 : 11:05:38
Hello friends,
plza help meeeeeeee

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-24 : 11:11:23
1 Define Last N-1 records
2 Post some sample data with expected result


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

janardhana
Starting Member

4 Posts

Posted - 2008-06-24 : 11:17:33
name price
---- -----
aaa 123.00
bbb 125.00
ccc 128.25
ddd 136.66
qqq 156.00
ggg 165.45


I want last n-1 records,means

ccc 128.25
ddd 136.66
qqq 156.00

i want avg of above prices

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-24 : 11:21:11
How do you identify that they are last n-1 records?
Do you have any other unqiue column in the table?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -