Built in Functions use with recordsets
От | Gordan Bobic |
---|---|
Тема | Built in Functions use with recordsets |
Дата | |
Msg-id | 00c701c05abc$7e8e9980$8000000a@localdomain обсуждение исходный текст |
Ответ на | backup and store oids (Gabriel Lopez <gabilm@dif.um.es>) |
Ответы |
Re: Built in Functions use with recordsets
|
Список | pgsql-general |
Hi. I'm trying to get an average value (avg()) of a certain attribute in a table. The snag is, I don't want this across a whole table. I only want it over a certain set of records. In effect, I want to do something like: SELECT somefield FROM sometable WHERE otherfield = 'criteria' ORDER BY thirdfield LIMIT 10 and then do an avg(somefield). Can this be done without using temp tables, in a single query? I tried making a function that does this, but even if I used temp tables, the function didn't work, claiming that the table didn't exist. Ideally, I want to do something like: SELECT avg ( SELECT somefield FROM sometable WHERE otherfield = 'criteria' ORDER BY thirdfield LIMIT 10 ) as somefieldname But the parser doesn't seem to like it. How can I do this? Thanks. Gordan
В списке pgsql-general по дате отправления: