Tutorial by Examples

First, let's setup the example table. -- Create a table as an example CREATE TABLE SortOrder ( ID INT IDENTITY PRIMARY KEY, [Text] VARCHAR(256) ) GO -- Insert rows into the table INSERT INTO SortOrder ([Text]) SELECT ('Lorem ipsum dolor sit amet, consectetur adipiscing elit') U...
If you want to sort your data numerically or alphabetically, you can simply use order by [column]. If you want to sort using a custom hierarchy, use a case statement. Group ----- Total Young MiddleAge Old Male Female Using a basic order by: Select * from MyTable Order by Group retur...

Page 1 of 1