Search
 
SCRIPT & CODE EXAMPLE
 

SQL

classement rang mysql 7

SELECT    a.first_name,
      a.age,
      a.gender,
        count(b.age)+1 as rank
FROM  person a left join person b on a.age>b.age and a.gender=b.gender 
group by  a.first_name,
      a.age,
      a.gender
Comment

classement rang mysql 7

CREATE TABLE person (id int, first_name varchar(20), age int, gender char(1));

INSERT INTO person VALUES (1, 'Bob', 25, 'M');
INSERT INTO person VALUES (2, 'Jane', 20, 'F');
INSERT INTO person VALUES (3, 'Jack', 30, 'M');
INSERT INTO person VALUES (4, 'Bill', 32, 'M');
INSERT INTO person VALUES (5, 'Nick', 22, 'M');
INSERT INTO person VALUES (6, 'Kathy', 18, 'F');
INSERT INTO person VALUES (7, 'Steve', 36, 'M');
INSERT INTO person VALUES (8, 'Anne', 25, 'F');
Comment

classement rang mysql 7

Bill    32  M   4
Bob     25  M   2
Jack    30  M   3
Nick    22  M   1
Steve   36  M   5
Anne    25  F   3
Jane    20  F   2
Kathy   18  F   1
Comment

PREVIOUS NEXT
Code Example
Sql :: convert sql to linq query online 
Sql :: MySQL can’t specify target table for update in FROM clause (Updating same table from same select inner join table) 
Sql :: SQLite3::SQLException: table "categories" already exists: CREATE TABLE "categories" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL 
Sql :: How to get distinct sets of rows using SQL (Oracle)? 
Sql :: select statement to print shortest name 
Sql :: calcul age 
Sql :: Aktor yang pernah terlibat lebih dari 3 film di sql 
Sql :: i wanted to select among the rows the highest value in mysql 
Sql :: generate series sqlserver 2005 
Sql :: distinct 
Sql :: mysql auto increment jumping 
Sql :: How to write triggers to increment or decrement the number of employees 
Sql :: sql date time query find 
Sql :: Sql Cursor: Implicit 
Sql :: MySQL - How to find word with the most similar beginning 
Sql :: ORACLE RANGE DATE USING CONNECT BY PER WEEK,MONTHS,ETC 
Sql :: oracle winter time change 
Sql :: liquibase default-schema in sql 
Sql :: MSSQL MAX VALOR 
Sql :: datagrip go to line 
Sql :: update user mysql 
Sql :: select concat alter table mysql 
Sql :: mysql_error replacement 
Sql :: downlaod database mysql workbench 
Sql :: sql server o arquivo solicitado não pode ser baixado 
Sql :: sqlite rename table 
Sql :: mysql 
Sql :: change order of sql columns 
Sql :: mask data in sql 
Sql :: mysql listing get a particu particular user firsdt 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =