{"id":93541,"date":"2022-03-18T20:21:51","date_gmt":"2022-03-18T20:21:51","guid":{"rendered":"https:\/\/www.red-gate.com\/simple-talk\/?p=93541"},"modified":"2022-03-21T15:28:20","modified_gmt":"2022-03-21T15:28:20","slug":"ordering-a-result-set-in-sql-server","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/learn\/ordering-a-result-set-in-sql-server\/","title":{"rendered":"Ordering a result set in SQL Server"},"content":{"rendered":"<p>A result set is easier to view when it\u2019s ordered, because the data can be browsed in a meaningful way. SQL Server does not guarantee a result set is ordered unless an <code>ORDER<\/code> <code>BY<\/code> clause is used. Data can be sorted in ascending and\/or descending order based on one or more columns when you use an <code>ORDER<\/code> <code>BY<\/code> clause. This articles explains different ways to use the <code>ORDER<\/code> <code>BY<\/code> clause for ordering a result set.<\/p>\n<h2>Syntax of the ORDER BY clause<\/h2>\n<p>Figure 1 contains the syntax for the <code>ORDER<\/code> <code>BY<\/code> clause as found in the <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/queries\/select-order-by-clause-transact-sql?view=sql-server-ver15\">Microsoft Documentation<\/a>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-93542\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2022\/03\/graphical-user-interface-text-application-email.png\" alt=\"An image showing the syntax of ORDER BY\" width=\"617\" height=\"330\" \/><\/p>\n<p><strong>Figure 1: ORDER BY syntax<\/strong><\/p>\n<h2>Test data<\/h2>\n<p>This article will cover a number of examples to show the different ways to use the <code>ORDER<\/code> <code>BY<\/code> clause. Each of these examples will select data from a table named <em>TestData. <\/em>If you want to follow along and run these examples, you can created this table by using the code in Listing 1.<\/p>\n<p><strong>Listing 1: Code to create <em>TestData<\/em> table<\/strong><\/p>\n<pre class=\"lang:tsql theme:ssms2012-simple-talk\">-- Create test data\r\nUSE tempdb;\r\nGO\r\nCREATE TABLE TestData (\r\nID INT, \r\nCharID CHAR(2),\r\nCityName VARCHAR(20),\r\nStateName VARCHAR(20),\r\nFounded SMALLINT);\r\n--Insert rows of test data\r\nINSERT INTO TestData VALUES\r\n(1,'1','Seattle','Washington',1851),\r\n(11,'11','Redmond','washington',1871),\r\n(12,'12','Bellevue','Washington',1953),\r\n(2,'2','Portland','oregon',1851),\r\n(5,'5','Grants Pass','Oregon',1887),\r\n(6,'6','Spokane','washington',1881),\r\n(7,'7','Salem','oregon',1842),\r\n(8,'9','Bend','Oregon',1905),\r\n(9,'9','Tacoma','Washington',1872);<\/pre>\n<h2>Sorting based on a single column<\/h2>\n<p>If a <code>SELECT<\/code> statement is run without and <code>ORDER<\/code> <code>BY<\/code> clause, SQL Server does not guarantee the record set produced in sorted order. To make sure a record set is returns data in sorted order an <code>ORDER<\/code> <code>BY<\/code> clause is needed. The code in Listing 2 does not have a <code>ORDER<\/code> <code>BY<\/code> clause, and produces the unordered results found in Report 1.<\/p>\n<p><strong>Listing 2: SELECT statement without an ORDER BY clause<\/strong><\/p>\n<pre class=\"lang:tsql theme:ssms2012-simple-talk\">SELECT StateName, CityName FROM TestData; <\/pre>\n<p><strong>Report 1: Unsorted Output when Listing 2 is run.<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-93543\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2022\/03\/word-image-1.png\" alt=\"An image showing the results of the query. The rows are in no particular order.\" width=\"140\" height=\"166\" \/><\/p>\n<p>The <code>ORDER<\/code> <code>BY<\/code> clause will sort data based on one or more columns. The code in Listing 2 selects the <code>StateName<\/code><em>, and <\/em><code>CityName<\/code> columns from the <code>TestData<\/code> table and sorts the results set based on the single column <code>StateName<\/code>.<\/p>\n<p><strong>Listing 3: Sort based on single column <\/strong><\/p>\n<pre class=\"lang:tsql theme:ssms2012-simple-talk\">USE tempdb;\r\nGO\r\nSELECT StateName, CityName From TestData\r\nORDER BY StateName;<\/pre>\n<p>Report 2 shows the results when Listing 3 is executed.<\/p>\n<p><strong>Report 2: Results created when Listing 3 is run<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-93544\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2022\/03\/word-image-2.png\" alt=\"An image showing the results of the query. The rows with Oregon in the state show up first.\" width=\"140\" height=\"160\" \/><\/p>\n<p>Report2 shows the results are sorted based only on the <code>StateName<\/code> column. The <code>CityName<\/code> column has not been sorted because the code in Listing 3 only specified to sort based on the <code>StateName<\/code> column. In order to also sort the <code>CityName<\/code> column, the code would have had to sort on that column as well. Multiple column sorts is covered later in the article.<\/p>\n<h2>Sorting in ascending or descending order<\/h2>\n<p>SQL Server supports two different sort orders: <code>ASC<\/code>, and <code>DESC<\/code>. Where <code>ASC<\/code> stands for ascending and <code>DESC<\/code> stands for descending. You can not specify ascending or descending spelled out, you can only specify the abbreviations of <code>ASC<\/code>, or <code>DESC<\/code>. When no sort order is identified in the <code>ORDER<\/code> <code>BY<\/code> clasue, like in Listing 3, SQL Server uses the default sort order which is ascending. The code in Listing 4 produces the same results as Listing 3. But in Listing 4 the code tells SQL Server to use ascending sort order, because ASC was specified after the <code>StateName<\/code> column.<\/p>\n<p><strong>Listing 4: Sort order of ASC specified<\/strong><\/p>\n<pre class=\"lang:tsql theme:ssms2012-simple-talk\">USE tempdb;\r\nGO\r\nSELECT StateName, CityName From TestData\r\nORDER BY StateName ASC;<\/pre>\n<p>The results could be sorted in descending order by specifying <code>DESC<\/code> next to the <code>StateName<\/code> column in the <code>ORDER<\/code> <code>BY<\/code> clause, as has been done in Listing 5.<\/p>\n<p><strong>Listing 5: Sorting results based on <em>StateName <\/em>in descending order<\/strong><\/p>\n<pre class=\"lang:tsql theme:ssms2012-simple-talk\">USE tempdb;\r\nGO\r\nSELECT StateName, CityName From TestData\r\nORDER BY StateName DESC;<\/pre>\n<p>The code in Listing 5 produces results shown in Report 3.<\/p>\n<p><strong>Report 3: The results from running Listing 5<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-93545\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2022\/03\/word-image-3.png\" alt=\"An image showing the results of the query. The rows with Washington show up first.\" width=\"142\" height=\"162\" \/><\/p>\n<p>You may have noticed that the <code>StateName<\/code> column contains some state names where the first character of the name is in uppercase and others in lowercase. You may be wondering why these values with similar cases where not sorted together. This is because they are sorted based on the collation of the <code>StateName<\/code> column, which, in this case, is case insensitive.<\/p>\n<h2>Collation setting of <em>TestData<\/em> table columns<\/h2>\n<p>The collation of the columns in my <code>TestData<\/code> table in <em>tempdb <\/em>is <em>SQL_Latin1_General_CP1_CI_AS<\/em>. This is because my <em>tempdb <\/em>got a collation of <em>SQL_Latin1_General_CP1_CI_AS<\/em> when it was created, and I didn\u2019t override the collation settings when creating my <code>TestData<\/code> table. Keep in mind not every <em>tempdb <\/em>database will have the same collation <em>SQL_Latin1_General_CP1_CI_AS<\/em>. The <em>tempdb<\/em> database is created each time SQL Server starts up. The collation setting of <em>tempdb<\/em> is created based on the collation of the model database. If your <em>tempdb <\/em>collation setting is not <em>SQL_Latin1_General_CP1_CI_AS<\/em> then you might see different sorting results when running any of the code in this article. To verify the collation setting of <em>tempdb <\/em>the code in Listing 6 can be executed.<\/p>\n<p><strong>Listing 6: Display the collation of <em>tempdb<\/em><\/strong><\/p>\n<pre class=\"lang:tsql theme:ssms2012-simple-talk\">SELECT DATABASEPROPERTYEX('tempdb','collation');<\/pre>\n<h2>How collation affects sorting<\/h2>\n<p>By default, SQL Server sorts character columns based on their column collation. All the <code>TestData<\/code> table character columns have a collation of <em>SQL_Latin1_General_CP1_CI_AS<\/em>. One way to verify the column collation setting is by running the code in Listing 7.<\/p>\n<p><strong>Listing 7: Displaying collation of <em>TestData <\/em>table columns<\/strong><\/p>\n<pre class=\"lang:tsql theme:ssms2012-simple-talk\">USE tempdb;\r\nGO\r\nSELECT c.name, \r\n       c.collation_name\r\n  FROM SYS.COLUMNS c\r\n  JOIN SYS.TABLES t ON t.object_id = c.object_id\r\n WHERE t.name = 'TestData';<\/pre>\n<p>Report 4 shows the results when I execute the code in Listing 7. If you have a different collation, you will see different results.<\/p>\n<p><strong>Report 4: Displaying collation of <em>TestData <\/em>columns<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-93546\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2022\/03\/word-image-4.png\" alt=\"An image showing the column names and collation of the character columns.\" width=\"247\" height=\"98\" \/><\/p>\n<p>By reviewing the <em>collation_name<\/em> column, you can see that each character data column in my <code>TestData<\/code> table has a collation of <em>SQL_Latin1_General_CP1_CI_AS.<\/em><\/p>\n<h2>Overriding the sort collation default<\/h2>\n<p>In order to override the the default collation setting of a column being sorted the <code>COLLATE<\/code> clause can be used. Listing 8 uses the <code>COLLATE<\/code> clause to get the columns of the same case to sort together.<\/p>\n<p><strong>Listing 8: Using COLLATE clause<\/strong><\/p>\n<pre class=\"lang:tsql theme:ssms2012-simple-talk\">USE tempdb;\r\nGO\r\nSELECT StateName, CityName FROM TestData\r\nORDER BY StateName COLLATE SQL_Latin1_General_CP1_CS_AS ASC;<\/pre>\n<p>By comparing Report 5 with Report 3, you can see that the state names with same case values are now sorted together when the <code>StateName<\/code> column was sorted based on a collation that is case sensitive.<\/p>\n<p><strong>Report 5: Output produce when Listing 8 was executed<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-93547\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2022\/03\/word-image-5.png\" alt=\"An image showing the results where the upper case items show up first.\" width=\"140\" height=\"168\" \/><\/p>\n<h2>Sorting numeric data<\/h2>\n<p>You would not think that sorting numbers would be a big deal. They are not when the numbers are stored in a numeric column like the <code>ID<\/code> column found in my <code>TestData<\/code> table. When a numeric value is stored in a character column, like the <code>CharID<\/code> column in my sample data, the results may not be sorted according to numeric order. To demonstrate this, execute the code in Listing 9.<\/p>\n<p><strong>Listing 9: Sorting a character column that contains numeric data<\/strong><\/p>\n<pre class=\"lang:tsql theme:ssms2012-simple-talk\">USE tempdb;\r\nGO\r\nSELECT CharID, StateName, CityName FROM TestData\r\nORDER By CharID;<\/pre>\n<p>Report 6 shows the results when Listing 9 is run.<\/p>\n<p><strong>Report 6: Output from Listing 9<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-93548\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2022\/03\/word-image-6.png\" alt=\"An image showing that the CharID column sorts all 1s before 2s.\" width=\"184\" height=\"166\" \/><\/p>\n<p>In Report 6, the numeric values in column <code>CharID<\/code> do not seem to be sorted correctly. Meaning the values <em>11<\/em>, and <em>12<\/em> appear before the value <em>2<\/em>. This is the correct sort order for character data, but not for numeric data. In order to get numeric data stored in a character column to sort correctly based on the numeric values, all that needs to be done is to use the <code>CAST<\/code> function in the <code>ORDER<\/code> <code>BY<\/code> clause, as shown in Listing 10.<\/p>\n<p><strong>Listing 10: Using CAST function in ORDER BY clause<\/strong><\/p>\n<pre class=\"lang:tsql theme:ssms2012-simple-talk\">USE tempdb;\r\nGO\r\nSELECT CharID, StateName, CityName FROM TestData\r\nORDER By CAST(CharID as TINYINT);<\/pre>\n<p>By using the <code>CAST<\/code> function to covert the <code>CharID<\/code> column to a numeric data type of <code>tinyint<\/code>, SQL Server will sort the <code>StateName<\/code> column, based on its casted numeric representation. I\u2019ll leave it up to you to run this code to verify that data is now sorted correctly for numeric values. Listing 10 also shows how a function or expression can be used in the <code>ORDER<\/code> <code>BY<\/code> clause.<\/p>\n<h2>Sorting based on column alias name<\/h2>\n<p>Alias names are also supported by the <code>ORDER<\/code> <code>BY<\/code> clause. This is especially useful when the sort order needs to be based on concatenating a couple of columns together, as shown in Listing 11.<\/p>\n<p><strong>Listing 11: Using alias name in ORDER BY clause<\/strong><\/p>\n<pre class=\"lang:tsql theme:ssms2012-simple-talk\">USE tempdb;\r\nGO\r\nSELECT CityName + ', ' + StateName as 'City and State' FROM TestData \r\nORDER BY 'City and State';<\/pre>\n<p>Report 7 shows the output when Listing 11 is executed.<\/p>\n<p><strong>Report 7: Ouput from Listing 11<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-93549\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2022\/03\/word-image-7.png\" alt=\"An image showing the results when the column alias is used in the ORDER BY clause.\" width=\"120\" height=\"170\" \/><\/p>\n<h2>Sorting based on ordinal position<\/h2>\n<p>The <code>ORDER<\/code> <code>BY<\/code> clause also supports sorting based on an ordinal position. An ordinal position is a numeric value that represents the column position in the set being sorted. In Listing 12, a set with two columns (<code>StateName<\/code> and <code>CityName<\/code><em>) <\/em>is being sorted based on ordinal postion 2, which in this case is the <code>CityName<\/code> column.<\/p>\n<p><strong>Listing 12: Sorting based on ordinal position<\/strong><\/p>\n<pre class=\"lang:tsql theme:ssms2012-simple-talk\">USE tempdb;\r\nGO\r\nSELECT StateName, CityName FROM TestData\r\nORDER By 2;<\/pre>\n<p>When the code in Listing 12 is executed, it produces the results in Report 8.<\/p>\n<p><strong>Report 8: Output when Listing 12 is run<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-93550\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2022\/03\/word-image-8.png\" alt=\"An image showing the data is sorted by ordinal position.\" width=\"142\" height=\"171\" \/><strong><br \/>\n<\/strong><\/p>\n<h2>Sorting based on multiple columns<\/h2>\n<p>All the examples so far have only showed how to sort a result set based on a single column. SQL Server also supports sorting data based on multiple columns. The code in Listing 13 shows how to sort my <code>TestData<\/code> using both the <code>StateName<\/code>, and <code>CityName<\/code> columns.<\/p>\n<p><strong>Listing 13: Sorting based on multiple columns<\/strong><\/p>\n<pre class=\"lang:tsql theme:ssms2012-simple-talk\">USE tempdb;\r\nGO\r\nSELECT StateName, CityName FROM TestData\r\nORDER By StateName, CityName;<\/pre>\n<p>Report 9 shows the output produced when Listing 13 is run.<\/p>\n<p><strong>Report 9: Ouput from Listing 13<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-93551\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2022\/03\/word-image-9.png\" alt=\"An image showing that the ORDER BY can contain multiple columns.\" width=\"136\" height=\"166\" \/><\/p>\n<p>The data is now sorted based on <code>StateName<\/code> and <code>CityName<\/code> columns in ascending order.<\/p>\n<h2>Sorting data in both descending and ascending order<\/h2>\n<p>When sorting based on multiple columns, SQL Server allows sorting each column using a different sort order. Listing 14 displays <code>StateName<\/code> and <code>CityName<\/code> values, where <code>StateName<\/code> is sorted in descending order and <code>CityName<\/code> is sorted in ascending order.<\/p>\n<p><strong>Listing 14: Sorting multiple columns using different sort orders<\/strong><\/p>\n<pre class=\"lang:tsql theme:ssms2012-simple-talk\">USE tempdb;\r\nGO\r\nSELECT StateName, CityName FROM TestData\r\nORDER By StateName DESC, CityName ASC;<\/pre>\n<p>Report 10 can be used to verify that <code>StateName<\/code> and <code>CityName<\/code> are sorted in <code>DESC<\/code> and <code>ASC<\/code> order, respectively.<\/p>\n<p><strong>Report 10: Output when Listing 14 is executed<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-93552\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2022\/03\/word-image-10.png\" alt=\"An image showing that one column can be descending and the other ascending.\" width=\"138\" height=\"165\" \/><\/p>\n<h2>Sorting data based on columns not in select list<\/h2>\n<p>Columns used in the <code>ORDER<\/code> <code>BY<\/code> clause don\u2019t have to be included in the selection list. To demonstrate this the code in Listing 15 can be run.<\/p>\n<p><strong>Listing 15: Sorting based on a column not in the selection list <\/strong><\/p>\n<pre class=\"lang:tsql theme:ssms2012-simple-talk\">USE tempdb;\r\nGO\r\nSELECT StateName, CityName FROM TestData\r\nORDER By Founded;<\/pre>\n<p>The output in Report 11 is generated when the code in Listing 15 is executed. These results are sorted based on the column <code>Founded<\/code>, which is not in the selection list.<\/p>\n<p><strong>Report 11: Results when Listing 15 is run<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-93553\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2022\/03\/word-image-11.png\" alt=\"An image showing that the ORDER BY can contain a column not showing up in the SELECT list.\" width=\"130\" height=\"163\" \/><\/p>\n<p>To verify the results are the order based on the <code>Founded<\/code> column value the code in Listing 16 can be run.<\/p>\n<p><strong>Listing 16: Code to identify when cities are founded<\/strong><\/p>\n<pre class=\"lang:tsql theme:ssms2012-simple-talk\">USE tempdb;\r\nGO\r\nSELECT Founded, StateName, CityName FROM TestData\r\nORDER By Founded;<\/pre>\n<p>I\u2019ll leave it up to you to run the code in Listing 16 to determine the dates that each city was founded.<\/p>\n<h2>Using offset fetch to return a subset<\/h2>\n<p>The <code>ORDER<\/code> <code>BY<\/code> clause also supports returning only a subset of rows from a sorted set by using the offset fetch option. To identify the subset of rows to display an <code>OFFSET<\/code> and <code>FETCH<\/code> value needs to be identified. The <code>OFFSET<\/code> value tells how many rows in the sorted set should be skipped before rows are returned. Whereas the <code>FETCH<\/code> option identifies the number of rows to return. The code in Listing 17 shows how to use the offset fetch option of the <code>ORDER<\/code> <code>BY<\/code> clause.<\/p>\n<p><strong>Listing 17: Using the Offset Fetch Option<\/strong><\/p>\n<pre class=\"lang:tsql theme:ssms2012-simple-talk\">USE tempdb;\r\nGO\r\nSELECT StateName, CityName, Founded FROM TestData\r\nORDER BY Founded\r\nOFFSET 2 ROWS FETCH NEXT 3 ROWS ONLY;<\/pre>\n<p>Report 12 shows the results when Listing 17 is executed.<\/p>\n<p><strong>Report 12: Output produced by Listing 17<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-93554\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2022\/03\/word-image-12.png\" alt=\"An image showing that by including the Founded column, you can see that it's sorted by that.\" width=\"173\" height=\"72\" \/><\/p>\n<p>The numeric value for <code>OFFSET<\/code> and <code>FETCH<\/code> options can be provided as expressions. Using an expressions and the offset fetch option is a great method of paging through a sorted set a few records at a time.<\/p>\n<h2>Limitations and restrictions<\/h2>\n<p>There are a number of limitations when using the <code>ORDER<\/code> <code>BY<\/code> clause. Below are a few of the common limitations worth noting:<\/p>\n<ul>\n<li>The <code>ORDER<\/code> <code>BY<\/code> clause is not valid in views, inline table-valued functions, derived tables, or sub-queries unless you also use the <code>TOP<\/code> clause in your statement.<\/li>\n<li>The combined size of all columns being sorted can not exceed 8060 bytes in length.<\/li>\n<li>If a top-level query contains a <code>UNION<\/code>, <code>EXCEPT<\/code> or <code>INTERSECT<\/code> clause then the <code>ORDER<\/code> <code>BY<\/code> clause can only appear at the end of the statement.<\/li>\n<li>Just like any other clause, when a table name is aliased in the FROM clause, only that table alias name can be referenced in the <code>ORDER<\/code> <code>BY<\/code> clause.<\/li>\n<\/ul>\n<p>For a complete list of limitations review the limitation section in the <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/queries\/select-order-by-clause-transact-sql?view=sql-server-ver15#limitations-and-restrictions\">Microsoft Documenation<\/a>.<\/p>\n<h2>Ordering a result set<\/h2>\n<p>Ordering a result set in a meaningful way makes it easier to review the returned data. While sorting data seems like a simple concept, in reality there are many nuances that need to be considered when sorting data, like default sort order, column collation settings, numerical data and use of aliases to name a few. Hopefully, this article provided enough examples to help out next time a result set needs to be produced in just the right sorted order.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To guarantee the order of a result set, you must use an ORDER BY clause. In this article, Greg Larsen explains what you need to know about ORDER BY.&hellip;<\/p>\n","protected":false},"author":78478,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[53,143525],"tags":[5134],"coauthors":[11330],"class_list":["post-93541","post","type-post","status-publish","format-standard","hentry","category-featured","category-learn","tag-sql-prompt"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/93541","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/78478"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=93541"}],"version-history":[{"count":5,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/93541\/revisions"}],"predecessor-version":[{"id":94138,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/93541\/revisions\/94138"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=93541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=93541"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=93541"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=93541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}