Chris Perryโ€™s Post

View profile for Chris Perry, graphic

Digital Intelligence at Experian | Founder of SQLShortReads.com

When teaching SQL to college students and business professionals, I find that they pick up on the ๐Ž๐‘๐ƒ๐„๐‘ ๐๐˜ clause very quickly as its use is rather intuitive given their familiarity with Microsoft Excel. At SQL Short Reads, I demonstrate how to use the ORDER BY clause to sort data based on the following: โ—ฝPre-existing attributes/columns โ—ฝThe results of aggregate functions โ—ฝAliases โ—ฝNon-selected attributes I also showcase how to implement more heavily customized sorting that goes beyond the standard ascending and descending sort methods and discuss how NULLS are handled when sorting data. ๐“๐ข๐ฉ: Sorting the output of a query can be a costly operation. In todayโ€™s business intelligence environment, your queries will likely originate from a data visualization tool such as Tableau or Power BI. Avoid including an ORDER BY clause in these queries because it is likely you and the consumers of your reports will be using the tool to sort the data displayed dynamically. In the case of Tableau, an ORDER BY clause is not allowed when using the toolโ€™s Custom SQL feature. You can learn more about the ORDER BY clause by visiting SQL Short Read's ORDER BY page. A link can be found in the comments section. ๐๐ซ๐š๐œ๐ญ๐ข๐œ๐ž ๐ฐ๐ก๐š๐ญ ๐ฒ๐จ๐ฎ ๐ฅ๐ž๐š๐ซ๐ง ๐ฎ๐ฌ๐ข๐ง๐  ๐’๐๐‹ ๐’๐ก๐จ๐ซ๐ญ ๐‘๐ž๐š๐โ€™๐ฌ ๐ฉ๐ซ๐š๐œ๐ญ๐ข๐œ๐ž ๐ฉ๐ซ๐จ๐›๐ฅ๐ž๐ฆ ๐ฌ๐ž๐œ๐ญ๐ข๐จ๐ง ๐œ๐จ๐ง๐ญ๐š๐ข๐ง๐ข๐ง๐  ๐จ๐ฏ๐ž๐ซ 160 ๐ฉ๐ซ๐จ๐›๐ฅ๐ž๐ฆ๐ฌ. ๐’๐ž๐ž ๐ญ๐ก๐ž ๐œ๐จ๐ฆ๐ฆ๐ž๐ง๐ญ๐ฌ ๐ฌ๐ž๐œ๐ญ๐ข๐จ๐ง ๐Ÿ๐จ๐ซ ๐š ๐ฅ๐ข๐ง๐ค. #SQL #SQLShortReads #DataAnalytics #DataEngineering

Chris Perry

Digital Intelligence at Experian | Founder of SQLShortReads.com

4w

โ—ป ORDER BY - https://sqlshortreads.com/sql-fundamentals/the-big-six/order-by-clause/ โ—ป For practice problems focused on the ORDER BY clause, see problem numbers 56-61 at https://sqlshortreads.com/sql-practice-problems/easy/

Like
Reply
Gaurav Gupta

Business Analyst | Product Owner | Project Management | Process Optimisation | Power BI | Ex EY consultant

3w

Great insights on the ORDER BY clause! It's true that sorting data can often feel intuitive for those familiar with tools like Excel. I appreciate how you break down the various ways to sort data, including by attributes, aggregate functions, and aliases. The tip about avoiding ORDER BY in queries originating from data visualization tools like Tableau and Power BI is particularly usefulโ€”saves on processing time and allows for more dynamic data interaction within the tools. For anyone looking to deepen their understanding and practice their skills, definitely check out SQL Short Readโ€™s practice problem section. It's an invaluable resource with over 160 problems to hone your SQL expertise. Thanks for sharing this!

John K. Moran

Helping retailers solve their data problems.

4w

Understanding the intricacies of SQL and its practical applications is necessary for both students and professionals in the data field. It's essential to delve deeper into these topics to enhance one's proficiency in SQL.

Like
Reply
See more comments

To view or add a comment, sign in

Explore topics