Re: [SQL] How to get last 10 rows in a table on a large database?
В списке pgsql-sql по дате отправления:
| От | Stoyan Genov |
|---|---|
| Тема | Re: [SQL] How to get last 10 rows in a table on a large database? |
| Дата | |
| Msg-id | 199911061136.NAA00556@lorna.digsys.bg обсуждение исходный текст |
| Ответ на | How to get last 10 rows in a table on a large database? (Alex@Icepick.com (Alex)) |
| Ответы |
Re: [SQL] How to get last 10 rows in a table on a large database?
|
| Список | pgsql-sql |
Hi. You should try this:begin transaction; declare tbl_cur cursor for select * from table order by datetime ASC; fetchforward 10 in tbl_cur;end transaction; This is true if you want THE LAST 10 rows from the selection - you order it in reverse and get the first 10. You are unable to say:begin transaction; declare tbl_cur cursor for .... ..... moveforward all in tbl_cur; fetch backward 10 in tbl_cur; ...........end transaction; because when you "move forward all" the result gets lost. If something is unclear, do write back... Stoyan Genov
В списке pgsql-sql по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера