query on query

Поиск
Список
Период
Сортировка
От Jayadevan M
Тема query on query
Дата
Msg-id 3411BBAFF5A2244FA405CC91D9473A602369B076@PBOX2.ibsplc.com
обсуждение исходный текст
Ответы Re: query on query  (Luca Ferrari <fluca1978@infinito.it>)
Список pgsql-general

Hi,

I have a table like this –

postgres=# \d m

       Table "public.m"

Column |  Type   | Modifiers

--------+---------+-----------

id     | integer |

marks  | integer |

 

postgres=# select * from m;

id | marks

----+-------

  1 |    27

  2 |    37

  3 |    17

  4 |    27

  5 |    18

(5 rows)

 

I wanted to get cumulative counts of students in different ranges – >90, > 80  , > 70  etc.

>10  5

>20  3

>30  1

>40 0

> 50 0

 

So each student may get counted many times, someone with 99 will be counted 10 times. Possible to do this with a fat query? The table will have many thousands of records.

 

 

Regards,

Jayadevan

 



DISCLAIMER: "The information in this e-mail and any attachment is intended only for the person to whom it is addressed and may contain confidential and/or privileged material. If you have received this e-mail in error, kindly contact the sender and destroy all copies of the original communication. IBS makes no warranty, express or implied, nor guarantees the accuracy, adequacy or completeness of the information contained in this email or any attachment and is not liable for any errors, defects, omissions, viruses or for resultant loss or damage, if any, direct or indirect."

В списке pgsql-general по дате отправления:

Предыдущее
От: David Carpio
Дата:
Сообщение: decrease my query duration
Следующее
От: "guxiaobo1982"
Дата:
Сообщение: =?gb18030?B?u9i4tKO6IFtHRU5FUkFMXSBDYW4ndCBjcmVhdGUg?= =?gb18030?B?cGxweXRob24gbGFuZ3VhZ2U=?=