xxxxxxxxxx
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.
xxxxxxxxxx
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.
xxxxxxxxxx
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.
xxxxxxxxxx
SELECT DISTINCT col1, col2, .
FROM table_name;
SELECT col1, MIN(col2)
FROM table_name
GROUP BY col1;
xxxxxxxxxx
CREATE TABLE order_details
( order_detail_id integer CONSTRAINT order_details_pk PRIMARY KEY,
order_id integer NOT NULL,
order_date date,
quantity integer,
notes varchar(200),
CONSTRAINT order_unique UNIQUE (order_id)
);
xxxxxxxxxx
CREATE TABLE Persons (
ID int NOT NULL UNIQUE,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int
);