select *
from customers
where email like '%@gmail.com';
select *
from customers
where email like '%@web.de';
select *
from customers
where email like '%@web.de'
   or email like '%@gmail.com';

select distinct SUBSTRING_INDEX(email, '@', -1) as domain
from customers;
# Nicht im Kurs, aber aus Interesse ausprobiert ---> Selektiert alle verschiedenen E-Mail Domains

select *
from customers
where firstname like 'M%';
select *
from customers
where firstname like 'M_____';

select firstname, lastname, age
from customers
where age between 20 and 30;

select *
from customers
where age not between 20 and 30;

select *
from customers
where firstname in ('Gitta', 'Dana', 'Anne');

select count(*)
from customers
where age not between 20 and 30; # 160

select count(distinct baby_names.name)
from baby_names
where name like 'Alex%'; # 20
select distinct baby_names.name
from baby_names
where name like 'Alex%';

select distinct baby_names.name
from baby_names
where name like '%m%';
select count(distinct baby_names.name)
from baby_names
where name like '%m%'; # 1183

select *
from baby_names
where year between 1900 and 1999;
select count(*)
from baby_names
where year between 1900 and 1999; # 161668
select count(*)
from baby_names
where year >= 1900
  and year <= 1999; # 161668

select *
from baby_names
where year = 1900
   or year = 1910
   or year = 1920
   or year = 1930
   or year = 1940
   or year = 1950
   or year = 1960
   or year = 1970
   or year = 1980
   or year = 1990;
select count(*)
from baby_names
where year = 1900
   or year = 1910
   or year = 1920
   or year = 1930
   or year = 1940
   or year = 1950
   or year = 1960
   or year = 1970
   or year = 1980
   or year = 1990; # 15307
select count(*)
from baby_names
where year in (1900, 1910, 1920, 1930, 1940, 1950, 1960, 1970, 1980, 1990); # 15307

select count(*)
from baby_names
where year like '19%0'; # 15307

select count(*)
from baby_names
where year % 10 = 0
  and year between 1900 and 1999; # 15307

select * from baby_names where name like 'Alex%' order by name desc;

select * from baby_names limit 50, 5; # offset, limit

select customers.firstname, customers.lastname, age from customers order by age desc, firstname;
select customers.firstname, customers.lastname, age from customers order by age desc, firstname limit 10;