Search
 
SCRIPT & CODE EXAMPLE
 

SQL

how to order a union sql

select *
from (
    select 1 as Rank, id, add_date from Table 
    union all
    select 2 as Rank, id, add_date from Table where distance < 5
    union all
    select 3 as Rank, id, add_date from Table where distance between 5 and 15
) a
order by rank, id, add_date desc
Comment

how to order by in sql with a union

Select id,name,age
From Student
Where age < 15
Union
Select id,name,age
From Student
Where Name like "%a%"
Order by name
Comment

PREVIOUS NEXT
Code Example
Sql :: create a table 
Sql :: select row with latest date mysql 
Sql :: SQL JOIN and Aliases 
Sql :: sql procedure 
Sql :: how to add amount between date in sql 
Sql :: desc sql 
Sql :: one to many sql 
Sql :: what is like operator in sql 
Sql :: what is auto increment in sql 
Sql :: year format in date mysql 
Sql :: postgres insert 
Sql :: plpgsql 
Sql :: not in sql 
Sql :: can you write relational algebra into sql queries 
Sql :: sql query to linq converter online 
Sql :: missing index for constraint error in mysql 
Sql :: drop all tables db2 
Sql :: ajax error exception handeling 
Sql :: t-sql cheat sheet 
Sql :: recursive query herarchical data sql server 
Sql :: SQL BETWEEN OPERATOR With Texts 
Sql :: where field is null sql knex 
Sql :: ring MySQL Restore Image From The Database 
Sql :: eneratingSchemaError: Some errors occurred while generating GraphQL schema: Type Query must define one or more fields. 
Sql :: ring execute SQL Statements on the database using the odbc_execute() 
Sql :: Find Last Fractal Function MQL4 
Sql :: create user oracle hash by value 
Sql :: REFRESH command materialized view pgadmin example 
Sql :: get enginge db mysql 
Sql :: sql add multiple values 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =