SQL/MX Report Writer Guide

Selecting Data for a Report
HP NonStop SQL/MX Report Writer Guide527194-002
3-15
Sorting the Data
Sorting the Data
The ORDER BY clause of the SELECT command determines the order in which rows
appear in the report. For example, the rows selected by the query in Figure 3-3 are
displayed in descending order by quantity available.
You can specify ascending or descending order, and you can specify more than one
column as the basis for sorting. For example, the query in Figure 3-4
selects entries in
which the quantity of parts ordered is greater than 30. The entries are arranged in
ascending order by part number and descending order by quantity ordered.
Figure 3-3. Rows Sorted by One Column
Note. If you specify more than one column as a basis for sorting, all the specified columns
should contain data from the same character set.
S >
>> SELECT * FROM SALES . PARTS
+> WHERE QTY_AVAILABLE <= 2500
+> ORDER BY QTY_AVAILABLE DESCENDING;
S> LIST NEXT 11;
PARTNUM PARTDESC PRICE QTY_AVAILABLE
5101
7301
6301
6201
3205
2003
7102
2001
6401
6400
6603
MONITOR BW, TYPE 2
SMART MODEM, 2400
GRAPHIC CARD, HR
GRAPHIC CARD, LR
HARD DISK 30 MB
GRAPHIC PRINTER,MB
SMART MODEM, 1200
GRAPHIC PRINTER,M1
STREAMING TAPE,M60
STREAMING TAPE,M20
PRINTER CONTROLLER
200.00
425.00
245.00
195.00
625.00
2000.00
275.00
1100.00
725.00
550.00
45.00
2400
2332
2331
2306
2209
2200
2200
2100
1308
1268
430
VST0303.vsd