Select last 10 rows from the table

19 views
Skip to first unread message

EJ-Boy Perez

unread,
Nov 5, 2015, 9:56:44 PM11/5/15
to OpenROAD Users Mailing List, Bodo.B...@actian.com
Hi everyone1

May I ask assistance on how to select the last 10 rows from the table. table sorted in ascending order based on its column name or_date.

thank you in advance.

Bodo Bergmann

unread,
Nov 6, 2015, 3:48:33 AM11/6/15
to EJ-Boy Perez, OpenROAD Users Mailing List

How about selecting the first 10 rows from the result set sorted in descending order,
then sorting those 10 rows ascending in the OpenROAD client using array.Sort() method?


Something like this (arr is an array of a user class for your result data):

 

  EXECUTE IMMEDIATE 'SELECT FIRST 10 or_date, col1, col2 FROM yourtable ORDER BY 1 DESC'

INTO :arr[i].or_date, :arr[i].col1, :arr[i].col2

  BEGIN

     i=i+1;

  END;
  COMMIT;

  arr.Sort(or_date = AS_ASC);

 

HTH.


Regards,

Bodo.

 

--

Bodo Bergmann

Senior Software Engineer

Actian | Engineering

Phone: +49.6103.3033.734

www.actian.com

 

GESELLSCHAFTSANGABEN: Geschäftsführer: Steven R. Springsteel, Stephen Mark Padgett, Markus Bockle

Sitz der Gesellschaft: Hamburg| Handelsregister: Amtsgericht Hamburg | HRB 135991| USt-IdNr: DE252449897

pwhite peercore

unread,
Nov 6, 2015, 7:41:52 PM11/6/15
to EJ-Boy Perez, Ingres and related product discussion forum, openroa...@googlegroups.com
Hi EJ Boy,

It is a good question to question direct to the Ingres forums. Here are a couple of good places to visit.

http://lists.planetingres.org/mailman/listinfo/info-ingres
http://community.actian.com/forum/




This is my attempt:


* select count(*) from customer\g
Executing . . .
│ 3867│


* select cust_code from customer order by cust_code offset 3857\g
Executing . . .
│cust_cod│
│YESNADEX│
│YINBRAV0│
│YONDEVT0│
│YORRICV0│
│YOTFOOV0│
│YUMBRUV0│
│YUMCHIEX│
│ZHECHIEX│
│ZHKMELEX│
│ZHOZHOEX│
(10 rows)


I agree with Bodo's simple approach. Which ever you choose, be sure to test for table scans and locking issues. Run debug: qep, io trace and lock trace for your selected approach.

Paul
--
You received this message because you are subscribed to the Google Groups "OpenROAD Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openroad-user...@googlegroups.com.
To post to this group, send email to openroa...@googlegroups.com.
Visit this group at http://groups.google.com/group/openroad-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/openroad-users/CO1PR06MB314F3A13D84338653234FED93280%40CO1PR06MB314.namprd06.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.

EJ-Boy Perez

unread,
Nov 10, 2015, 7:38:07 PM11/10/15
to OpenROAD Users Mailing List, ecper...@gmail.com

Thank you everyone for the nice suggestions....
Reply all
Reply to author
Forward
0 new messages