Free tools Windows power users keep installed
One-click scans. No signup required.
In SQL’s logical processing model, SELECT comes before ORDER BY: FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY. That order explains why ORDER BY can use a SELECT alias, why DISTINCT compares projected values, and why sorting by a non-unique value can leave tied rows in an unpredictable order.
What SELECT and ORDER BY do
SELECT shapes the result
SELECT is projection: it determines which attributes appear in the output and can compute expressions such as arithmetic, CASE, casts, and date functions. SELECT * expands to the columns visible from the input relation. Projection changes the shape of each row; it does not, by itself, filter rows.
ORDER BY sequences the result
ORDER BY specifies the required order of the final output. Each sort item is an expression with a direction. Multiple items are compared lexicographically: SQL compares the first key, then uses the next key to order rows tied on the earlier one.
Why the logical order matters for aliases
The SQL text writes SELECT before ORDER BY, and the logical model evaluates ORDER BY after SELECT. Consequently, a column alias created in the select list is available to ORDER BY. Earlier clauses such as WHERE, GROUP BY, and HAVING cannot generally refer to that alias, because they are logically processed before the select list.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware match#1 Best Overall
- Reliable Plug and Play: The USB receiver provides a reliable wireless connection up to 33 ft (1), so you can forget about drop-outs and delays and you can take it wherever you use your computer
- Type in Comfort: The design of this keyboard creates a comfortable typing experience thanks to the low-profile, quiet keys and standard layout with full-size F-keys, number pad, and arrow keys
- Durable and Resilient: This full-size wireless keyboard features a spill-resistant design (2), durable keys and sturdy tilt legs with adjustable height
- Long Battery Life: MK270 combo features a 36-month keyboard and 12-month mouse battery life (3), along with on/off switches allowing you to go months without the hassle of changing batteries
- Easy to Use: This wireless keyboard and mouse combo features 8 multimedia hotkeys for instant access to the Internet, email, play/pause, and volume so you can easily check out your favorite sites
Expressions in a single SELECT list are treated together. One expression cannot use a sibling expression’s alias as though it had already been computed. If an expression must be reused, put it in an earlier query layer, such as a subquery or common table expression.
How DISTINCT decides which rows are duplicates
DISTINCT removes duplicate projected results. Its comparison keys are the values of the selected expressions, not every column in the source row. For example, casting or rounding values, extracting a date from a timestamp, or producing NULL can change which rows count as duplicates.
Rank #2
- Dependable wireless connection: Enjoy the reliability and convenience of 2.4 GHz connectivity with your logitech wireless keyboard and mouse combo, wireless range up to 10 meters away at home, or work.
- Full-Size Wireless Keyboard: Comfortable, quiet typing on a familiar keyboard layout with palm rest, spill-resistant design, and media keys. This wireless keyboard and mouse logitech has easy-access to media keys
- Plug and Play: MK345 works seamlessly with Windows, macOS, and ChromeOS. Experience hassle-free setup with the logitech mk345 wireless combo and wireless keyboard mouse combo for various operating systems.
- Long-lasting Battery: The MK345 combo offers a full size keyboard battery life of up to 3 years and a mouse battery life of 18 months (1); batteries included
- Comfortable Right-handed Mouse: This wireless USB mouse with dongle works well for this wireless mouse and keyboard combo, featuring a contoured shape for all-day comfort and smooth, precise tracking and scrolling for easier navigation.
SELECT DISTINCT customer_id, DATE(created_at) AS created_day
FROM orders
WHERE status = 'shipped';
Conceptually, the query filters to shipped orders, projects customer_id and the computed date, then removes duplicate pairs of (customer_id, created_day). Two source rows with the same pair produce one result even if other, unselected source columns differ.
Can ORDER BY use a column that is not selected?
Often, yes. A sort expression can be used as a dependency for ordering without appearing in the returned row. For example, SELECT id FROM events ORDER BY event_time DESC can return only id while sorting by event_time. The precise restrictions vary by SQL dialect, particularly when DISTINCT is involved, so check the rules for the database you use.
Rank #3
- 【Ergonomic Wireless Keyboard Mouse 】: Wireless ergonomic keyboard is equipped with adjustable height tilt legs to increase comfort and prevent your wrists injury when typing for a long time. The full size wireless keyboard with numeric keypad and 12 multimedia shortcut keys, such as play/ pause, volume increase and decrease, and email, to help you improve work efficiency
- 【Stable & Reliable Wireless Connection】: This wireless keyboard and mouse combo share the same USB receiver(stored in the mouse), and they can also be used separately. Plug & play, no need to download any software, 2.4 GHz wireless provides a powerful and reliable connection up to 33 feet(10m) without any delays.You can enjoy the convenience and freedom of wireless connection at home or at work
- 【Comfortable Optical Mouse】: This compact lightweight wireless mouse features a hand-friendly contoured shape for all-day comfort, and smooth, precise tracking.1600 DPI to meet your daily needs. Perfect for home & office work and entertainment
- 【Long Battery Life】: Up to 365 Days of battery life for keyboard and mouse wireless, say goodbye to the hassle of charging cables and replacing batteries. After 10 minutes of inactivity, the wireless keyboard mouse combo will automatically go into sleep mode to save energy. The wireless keyboard requires one AAA battery, and the wireless mouse requires one AA battery.
- 【Less Noise, More Quiet Keys】: Soft membrane keys provide a quiet and comfortable typing experience, So you can type with confidence on a wireless keyboard crafted for comfort, precision and fluidity. The wireless mouse adopts silent micro-motion technology, which is almost completely silent when clicked. No more concerns about disturbing others.
Some systems also accept ordinal positions such as ORDER BY 1, meaning the first select-list item. This is fragile: if the select-list order changes, the sort meaning changes too. An explicit column name or expression is easier to review and maintain.
Make sort order complete when ties matter
Ordering by a non-unique key does not specify the order among rows that share that key. If repeatable ordering matters, add a stable unique tie-breaker. Here, equal scores are ordered by ascending ID:
Rank #4
- 【Lag-free & Efficient】Stable and reliable connection of wireless keyboard and mouse is up to 10m(33ft). This combo share a nano USB receiver, no need to take up additional USB ports (Also the wireless keyboard and mouse can also be used separately). Plug and play, no software needed,convenient and efficient.
- 【Quiet & Type in Comfort】Wireless keyboard come with adjustable height tilt legs to increase comfort and prevent your wrists injury when typing for a long time.Our wireless keyboard adopts a silent structure. Soft membrane keys provide a quiet and comfortable typing experience.The wireless mouse is quiet without any clicking sound also.So whether at home or in the office, you can use this combo as you please without worrying about disturbing others.
- 【Full Size Keyboard】This keyboard saves desktop space while retaining its full size.The full size wireless keyboard with numeric keypad and 12 multimedia shortcut keys, such as play/ pause, volume increase and decrease, and search, to help you improve work efficiency.
- 【Auto Power Saving Function】Wireless keyboard and mouse have a smart auto-sleep mode to save power for long battery life. They will enter sleep mode after stop using a while(Refer to the instructions for details). Unplug the receiver or after the PC shutdown, they will enter sleep mode too.You can press any keys to wake. (battery life may vary based on user and computing conditions)
- 【Comfortable Optical Mouse】This silent wireless mice provides 3 adjustable DPI (800/1200/1600) to meet your different needs in terms of sensitivity.The compact lightweight design of wireless mouse and a hand-friendly contoured shape for all-day comfort, and smooth, precise tracking. Very suitable for office and daily use.
SELECT id, score
FROM results
ORDER BY score DESC, id ASC;
This matters especially with LIMIT, TOP, or OFFSET/FETCH: the ordering determines which rows are returned in a limited page or result. Without a unique final sort key, tied rows may appear in different relative orders across executions.
Account for NULLs and collation
NULL placement and text collation affect comparisons, and SQL dialects differ in their defaults. If the required NULL position matters, specify it where supported, for example ORDER BY last_name ASC NULLS LAST. Collation determines how text values compare and sort; use the appropriate collation when a particular case, accent, or language ordering is required.
Best Value
- 【Ergonomic Comfort – Perfect for Long Workdays.】The keyboard features a adjustable height tilt legs and a ergonomic design, allowing you to set the perfect typing angle to reduce wrist strain. The mouse’s symmetrical ultra-slim shape fits both left and right hands naturally. Both keyboard and mouse keep you comfortable and productive through marathon sessions.
- 【Whisper-Quiet Operation – Ideal for Shared or Open Spaces】The silent mouse and low-noise keyboard let you click and type without disturbing others. No more annoying clicking sounds during video calls or focused work – just smooth, quiet performance that respects the people around you when you are at home office, library, or an open-plan workspace.
- 【Smart Power Efficiency – Never Worry About Battery Life】With an auto-sleep function, battery level indicator, and energy-saving design, this keyboard mouse combo keeps working when you need it. The power indicator alerts you before power runs low, so you’ll never be caught off guard in the middle of an important task, suitable for student or freelancer moving between coffee shops, classes, and home. The wireless keyboard requires one AAA battery, and the wireless mouse requires one AA battery.
- 【Universal System Compatibility – One Set for All Your Devices】Wireless keyboard and mouse works seamlessly with Windows 11/10/8/7, Mac OS, Chrome OS, and Linux. No driver hunting or compatibility worries – just plug and play. And compatible with laptop desktop PC computer notebook Chromebook Mac MacBook iMac and more. The full-size 104-key layout ensures you have all the functions you need, no matter the platform.
- 【One Shared USB Receiver for Keyboard and Mouse – True Plug-and-Play Convenience】The mouse stores a single 2.4GHz USB receiver right inside its body, so you’ll never lose it. Use the receiver to connect both the keyboard and the mouse simultaneously – or use each device separately if needed. With reliable, lag-free wireless performance up to 10 meters (33 feet), you can control your screen from across the room, perfect for a TV or projector for entertainment.
SELECT customer_id, last_name
FROM customers
ORDER BY last_name ASC NULLS LAST, customer_id DESC;
This sorts last names ascending, places NULL last names at the end, and sorts equal last names by customer ID descending. The exact syntax and defaults are database-specific.
Examples of expression-based sorting
A sort key can be an expression rather than a bare column. The ID below provides a tie-breaker after the price expression:
SELECT id, price_usd
FROM products
ORDER BY (price_usd * 1.0) DESC, id;
The multiplication by 1.0 may be equivalent to sorting by numeric price in many systems, but expressions can matter when they alter type or comparison behavior. The final id key makes tied expression values deterministic if id is unique.
Logical order is not the execution plan
The clause sequence describes the query’s conceptual meaning, not a command that the database must execute literally in that physical order. An optimizer may prune columns not needed for filtering, joining, duplicate removal, or sorting; simplify aliases or constants; avoid a sort when an index already supplies the required order; or remove a redundant DISTINCT when keys or functional dependencies guarantee uniqueness. Such rewrites must preserve the query’s result.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteFor SQL Server pagination, TOP and OFFSET-FETCH operate after the SELECT-related phases, and ORDER BY determines which rows are selected. Microsoft’s guidance recommends considering indexes that support the ordering columns to help avoid unnecessary scanning and sorting. See the SQL Server ORDER BY documentation and its OFFSET-FETCH guidance for SQL Server-specific details.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




