Re: [Postgresql-it] Query con limit centrata
- From: Stefano Reksten <sreksten@xxxxxx>
- To: postgresql-it@xxxxxxxxxxxxxxxxx
- Date: Wed, 13 Apr 2005 13:22:52 +0200
At 13.03 13/04/2005, you wrote:
campo1
-------
1
2
3
4
5
6
7
8
9
10
vorrei fare una funzione f(5,1) ad esempio che mi restituisca:
Res
---
4
5
6
quindi centrata in 5 con un limit di 1 sia sopra che sotto
O non ho capito il tuo problema o è veramente anche troppo semplice...
intendi qualcosa del tipo
create function f(int centro, int limite) returns setof <tipo del campo1> as '
select campo1 from tabella where campo1 between centro - limite and
centro + limite
' language plpgsql;
?
(NB l'ho scritta di getto e pure per la sintassi presente dalla 8 senza
testarla)
Ciao,
Stefano
Other related posts: