Search
 
SCRIPT & CODE EXAMPLE
 

SQL

MySQL Quartiles in SQL query

SET @number_of_rows := (SELECT COUNT(*) FROM LuxLog);
SET @quartile := (ROUND(@number_of_rows*0.25));
SET @sql_q1 := (CONCAT('(SELECT "Q1" AS quartile_name , Lux, Sensor FROM LuxLog ORDER BY Lux DESC LIMIT 1 OFFSET ', @quartile,')'));
SET @sql_q3 := (CONCAT('( SELECT "Q3" AS quartile_name , Lux, Sensor FROM LuxLog ORDER BY Lux ASC LIMIT 1 OFFSET ', @quartile,');'));
SET @sql := (CONCAT(@sql_q1,' UNION ',@sql_q3));
PREPARE stmt1 FROM @sql;
EXECUTE stmt1;
Comment

PREVIOUS NEXT
Code Example
Sql :: sqlc yml settings version 1.14 
Sql :: fonction stockée pl/sql 
Sql :: PROSYS SQL 
Sql :: select nth row in mysql 
Sql :: mysql where sum 0 
Sql :: deny select insert update delete sql 
Sql :: mysql update even / odd rows 
Sql :: convert sqlalchemy.util._collections to list of string 
Sql :: sql query contains multiple ids 
Sql :: mysql db dump restore max file size issue 
Sql :: call object contructor and call methods of object 
Sql :: how many columns can be used for creating index? 
Sql :: BSD sed: extra characters at the end of d command 
Sql :: calcular edad en oracle 
Sql :: sql create tablwe 
Sql :: suse status MySQL 
Sql :: python sqlalcahmey compare datetime using AND_ or OR_ 
Sql :: start whith system mysql 
Sql :: denormalise SQL command 
Sql :: MySQL - How to find word with the most similar beginning 
Sql :: azure sql-datenbank 
Sql :: db visualizer mssql 
Sql :: mysql vs sql server performance benchmark 
Sql :: cast find duration in sql 
Sql :: show * from table mysql 
Sql :: select from where 
Sql :: SQL Backup Only New Changes in SQL 
Sql :: how to enter psql shell 
Sql :: ORACLE SUBSTRING SYNTAX 
Sql :: % Wildcard in SQL 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =