SQL Primer: Using ORDER BY


This example shows how to dynamically sort a Recordset using the ORDER BY clause with a given field. Click on each COLUMN HEADER to specify the sort order.
ProductType ProductName ProductDescription UnitPrice
SleepingBag North Face Sunspot windproof, water-resistant, even heat distribution, storage sack included, red (re) $ 390
SleepingBag Polar Star ultralight goose-down insulated alpinist's bag, contour closure with locking zipper, storage sack included, green (gn) $ 310
SleepingBag Big Sur generously cut sleeping bag, goose-down with polyester taffeta, cotton storage sack included, blue (bl) $ 200
SleepingBag Cascade backpacking sleeping bag, goose down with nylon shell, locking zipper, storage sack included, choice of zipper location, blue (bl) $ 210
Boot Everglades medium-weight, waterproof leather boots, good traction, brown (br) $ 98
Boot Rockies lightweight Nubuck leather/nylon, water-resistant boots, polyurethane soles, green/gray (gg) or green/brown (gbn) $ 78
Boot Sierras Nubuck, water-resistant leather boots, rubber soles, dark brown (db) $ 87
Boot Dunes lightweight nylon/suede hiking boots, light green (lg) $ 98
Tent Starlight 4-person dome tent, roomy, vaulted pole sleeves, black/gray (bg) $ 425
Tent Galaxy durable 3-person all-purpose tent, maximum headroom, no-leak floor, beige/purple (bp) $ 535
Tent Aptos lightweight 2-person backpacking tent, adjustable vents, canopy loops, green/black (gbk) $ 335
Tent Scirocco warm-climate 2-person tent, compact, lightweight, bug protection, black/gray/purple (bgp) $ 190
Parka Alpine durable, breathable, ripstop nylon parka, guaranteed to keep you dry, red (re), blue (bl), or black (bk) $ 188
Parka Campos reinforced, waterproof, 2-layer nylon parka, interior/exterior pockets, blue (bl) $ 250
Parka Sahara outer-shell drawstring parka with zippered pockets, green (gn) or blue (bl) $ 114
Parka Crystal lightweight, traditional parka with nylon lining, hooded, purple (pu) or blue (bl) $ 125
Supplies Wolfgang multifuel cook stove, white gas or unleaded $ 59
Supplies Surelite cold-starter, 80/20 butane/propane cartridges $ 4
Supplies Daytrip First Aid Kit nylon pouch, comprehensive kit for day or weekend trips $ 31
Supplies Scoutpride all-purpose cook set, stainless-steel nesting pots of 1, 2, and 3 liters, includes lids and fry pans $ 44.75
Backpack Aces women's cut, adjustable waistbelt and stays, floating hipbelt, top-loading, side pockets, blue/black (bb) $ 325
Backpack University multipurpose, with padded backpad and hipbelt, side pockets, bound seams, blue (bl) $ 140
Backpack Pacific weekender, adjustable hipbelt, side pockets, easy-access wraparound zipper, blue (bl) $ 151
Backpack Conestoga anti-sway, shoulder-yoke pack for long trips, aluminum frame, front fanny-pack conversion, lower sleeping bag compartment, heavy duty nylon, red (re) $ 175
Carabiner Petzl Spirit Locking pear shaped $ 13
Carabiner Basic Black Oval $ 14
Carabiner Gold-Series Locking D Strong yet lightweight $ 7
Carabiner Black Diamond Quicksilver II straight $ 9
Crampon Venus hinged crampons for snow and moderate ice, step-in bindings, one size fits men's 4-12 $ 99
Crampon Wafflestomper hiking/trekking nontechnical crampons, hinged frame, straps included, one size fits men's 5-12 $ 109
Crampon Edgehugger classic technical ice-climbing crampons, rigid, mono points available, one size fits men's 5-14 $ 145
Crampon Glory Grip mixed ice and waterfall-climbing crampons, step-in bindings, rigid, vertically oriented front points $ 149
Harness Black Diamond Bod multipurpose, padded waist, adjustable droppable leg loops, gear racking padded waist, adjustable droppable leg loops, gear racking, black $ 32
Harness Black Diamond Alpine Bod lightweight, adjustable, droppable leg loops, black (bk) $ 29
Harness El Capitan comfort harness, generous padding, full-strength haul loop $ 52
Harness Petzl Mercury padded waist and leg loops, self-locking buckle, pre-threaded, gear racking, assorted colors $ 72
Pants Women's 4-pocket pants medium-weight cotton, pre-washed, green (gn) or beige (sa) $ 32
Pants Men's 8-pocket conversion pants 100% cotton canvas, 34" inseam, gray (gr) or brown (br) $ 46
Pants Unisex drawstring pants lined, lightweight nylon, green (gn) or brown (br) $ 48
Pants Unisex hiking pants heavy-duty, water-resistant nylon, lightweight, green (gn) or beige (sa) $ 55
RockShoes Gibralter high-performance endurance shoes $ 150
RockShoes Plymouth semi-flexed shoes, basic comfort $ 125
RockShoes Morro all-around, durable shoes with Stealth soles $ 84
RockShoes Tuscany all-around shoes with slipper/shoe design $ 124
Shirt Women's woven tee short-sleeve, breathable henley, 100% cotton knit, blue (bl), beige (sa) or green (gn) $ 29
Shirt Men's loose weave polo 100% breathable cotton, blue (bl), white (wh), red (re), or beige (sa) $ 45
Shirt Men's button-down short-sleeve, durable, 100% cotton, button-flap pockets, blue (bl), red (re), or beige (sa) $ 42
Shirt Unisex long-sleeve button-down parachute-style, cotton/nylon blend, multiple pockets, green (gn) or beige (sa) $ 75

The SQL Source of the Recordset is as follows:

SELECT ProductType, ProductName, ProductDescription, UnitPrice FROM Products2

The sort orders are by default ascending, except for the UnitPrice field, which is sorted from highest to lowest.

Go Top   |   Return to DB101 ADO Samples