Ejemplo 1: seleccione el recuento de valores distintos sql
SELECT COUNT (DISTINCT column-name) FROM table-name
Ejemplo 2: como seleccionar un elemento único en sql
DISTINCT
- select distinct * from employees; ==>
retrieves any row if it has at
least a single unique column.
- select distinct first_name from employees; ==>
retrieves unique names
from table. (removes duplicates)
- select distinct count(*) from employees;
retrieve number of unique rows
if any row has at least a single unique data.
Ejemplo 3: el servidor SQL selecciona filas por columna distinta
SELECT a.*
FROM emails a
INNER JOIN
(SELECT email,
MIN(id) as id
FROM emails
GROUP BY email
) AS b
ON a.email = b.email
AND a.id = b.id;
Ejemplo 4: como encontrar un elemento único en sql
DISTINCT
- select distinct * from employees; ==>
retrieves any row if it has at
least a single unique column.
- select distinct first_name from employees; ==>
retrieves unique names
from table. (removes duplicates)
- select distinct count(*) from employees;
retrieve number of unique rows
if any row has at least a single unique data.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)