Entries in select (2)

How do I select all columns in q?

By listing nothing at all in the select clause:

q)table: ([] x: 5 10 15 20; y: 1 2 3 4)
q)table
x  y
----
5  1
10 2
15 3
20 4
q)select from table where x > 10
x  y
----
15 3
20 4
q)

or SQL via "s)":

q)s)select * from table where x > 10
x y
----
15 3
20 4
q)

See also: $QHOME/s.k

How do I efficiently retrieve the first n rows of a query result?

select[n]. The first example below retrieves the first 10 rows, whereas the second example retrieves the last 10 rows:

select [10] from table where date=2011.02.27
select [-10] from table where date=2011.02.27

If the table is in memory, you can use the virtual column i to retrieve a specific range of rows:

select from table where i within (begin; end)

If you want to retrieve specific rows by index from a partitioned table, use .Q.ind.

C.f. # (take) and sublist