loading..
Русский    English
15:59

The sorting and NULL values page 3

The fact that NULL-values go first when sorting in ascending order ( SQL(Structured Query Language) is a database computer language designed for the retrieval and management of data in relational database management systems (RDBMS), database schema creation and modification, and database object access control management.SQL Server), we can use in the "useful purposes".

Assume that we need to deduce the list of flights in which flights from Rostov should go first, and then the others in alphabetic order of departure cities.

Here the function NULLIF(town_from,'Rostov'), which will return NULL if city of departure is ' Rostov ', very opportune to be useful.

The problem is being solved with the following query:

Console
Execute
  1. SELECT trip_no, town_from, town_to
  2. FROM Trip
  3. ORDER BY NULLIF(town_from,'Rostov'), trip_no;
Bookmark and Share
Pages 1 2 3
Tags
aggregate functions Airport ALL AND AS keyword ASCII AVG Battles Bezhaev Bismarck C.J.Date calculated columns Cartesian product CASE cast CHAR CHARINDEX Chebykin check constraint classes COALESCE common table expressions comparison predicates Computer firm CONSTRAINT CONVERT correlated subqueries COUNT CROSS APPLY CTE data type conversion data types database schema DATEADD DATEDIFF DATENAME DATEPART DATETIME date_time functions DDL DEFAULT DEFAULT VALUES DELETE DISTINCT DML duplicates edge equi-join EXCEPT exercise (-2) More tags
The book was updated
month ago
обменять с промсвязьбанк
©SQL-EX,2008 [Evolution] [Feedback] [About] [Links] [Team]
All right reserved.