This month's discount Comprehensive Database Performance Health Check · Testimonials
SQLAuthority with Pinal Dave
Home
  • Consulting
    • Health Check
  • Free Videos
  • All Articles
    • AI
    • SQL Performance
    • SQL Tips and Tricks
    • Interview Questions and Answers
    • SQL Puzzle
    • SQL Video
    • SQLAuthority News
    • Personal
  • Books
  • Consulting
A sloping egg rack at a market stall, one hand taking the oldest egg from the front, another adding a fresh one.

DELETE TOP With ORDER BY: Removing the Oldest Rows First

May 1, 2024
Pinal Dave
SQL Tips and Tricks
CTE, SQL Delete, SQL Order By, SQL Server, SQL Top

Use DELETE TOP safely through an ordered CTE, preview oldest rows, apply a supporting index, and remove eligible rows in bounded batches.

Read More
A sieve holds a few kernels above a trough full of sifted grain, with a larger mound behind

TOP N Sort: Why a Small TOP Still Reads the Whole Table

November 3, 2021
Pinal Dave
SQL Performance
Execution Plan, SQL Index, SQL Order By, SQL Server, SQL Top

Explain TOP N Sort, compare an indexed ordered access path, and align filter and sort keys before adding indexes for frequent requests.

Read More
distinct

SQL SERVER – Distinct and ORDER BY

November 5, 2020
Pinal Dave
SQL Tips and Tricks
Execution Plan, SQL Operator, SQL Order By, SQL Scripts, SQL Server

I have made note that ORDER BY is not required when DISTINCT is used. Let us understand the same subject in detail. Let us learn today.

Read More
order by a parameter

SQL SERVER – How to Order By a Parameter?

June 8, 2020
Pinal Dave
SQL Tips and Tricks
SQL CASE, SQL Order By, SQL Scripts, SQL Server

We figured out that there was a very poor code written in one of the Stored Procedure’s Order By clause. Let us learn today how to order by a parameter.

Read More
Orders Data

SQL SERVER – Group By Orders Data by Columns Ascending

October 23, 2019
Pinal Dave
SQL Tips and Tricks
SQL Group By, SQL Order By, SQL Scripts, SQL Server

The question was about Group By Orders Data by Columns Ascending. DBA asked me an interesting question referring to my older blog.

Read More
Cooking spoons hang in ascending bowl sizes regardless of their handle colors

How to Sort a Varchar Column Storing Integers with Order By? – Interview Question of the Week #206

December 30, 2018
Pinal Dave
SQL Interview Questions and Answers
SQL Datatype, SQL Order By, SQL Scripts, SQL Server, SQL String

How do you sort a Varchar column storing integers with Order By when you cannot change the datatype? Here are two simple solutions I shared with a developer.

Read More
An icon set with time, calendars and checkmarks.

SQL Server – Formatted Date and Alias Name in ORDER BY Clause

September 28, 2018
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Function, SQL Order By, SQL Scripts, SQL Server

Format a date with CONVERT, then use its alias in ORDER BY, and the rows come back in a different order. Here is a simple example of this formatted date surprise.

Read More
1 2 3 Next
  • Books
  • Testimonials
  • Privacy Policy

© 2006 – 2026 All rights reserved. pinal @ SQLAuthority.com