Search
 
SCRIPT & CODE EXAMPLE
 

SQL

sql max of two values

-- For SQL Server >= 2008
SELECT [Other Fields],
  (SELECT Max(v) 
   FROM (VALUES (date1), (date2), (date3),...) AS value(v)) as [MaxDate]
FROM [YourTableName]

/* Note (from comments): From value(v), "value" is the alias for the 
 * virtual table and "v" is the name of the virtual column of the date values.
 */
Comment

2 max value in sql

SELECT MAX (column_name) 
FROM table_name 
WHERE column_name NOT IN (SELECT Max (column_name) 
                          FROM table_name);
Comment

PREVIOUS NEXT
Code Example
Sql :: mysql query to select the highest value 
Sql :: sqlalchemy case insensitive like 
Sql :: drop database mysql 
Sql :: get only one row in mysql 
Sql :: pl sql create function 
Sql :: convert minutes to hours sql 
Sql :: sqlite clear console 
Sql :: insert multiple rows from another table sql 
Sql :: plpgsql coalesce equivalent for empty string 
Sql :: find the all the constraints in a specific table 
Sql :: oracle last connexion 
Sql :: sql not equal to operator 
Sql :: check ksql db health 
Sql :: mysql get 2nd value in comma separated list 
Sql :: insert using condition postgres 
Sql :: postgres between dates 
Sql :: sql cte example 
Sql :: oracle diskgroup 
Sql :: left join sql 
Sql :: plsql find location of procedure 
Sql :: sql update by id 
Sql :: mysql shell 
Sql :: oracle sql get value from several rows and concatenate strings 
Sql :: postgresql show tables 
Sql :: insert into table sql 
Sql :: substract variable amount of minutes from timestamp postgresql 
Sql :: sql cross apply vs join 
Sql :: mysql update LAST_INSERT_ID() 
Sql :: not null sql 
Sql :: oracle sql procedure return value 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =