SQL - Less e Bigger than, AND, OR, Between, Cast
Função Less Than e Bigger than (a sintaxe é a mesma):
select
title,
stock_quantity
from books
where stock_quantity < 100
Função AND
select
title,
stock_quantity,
pages
from books
where stock_quantity < 100 AND pages >300
Função OR
select
title,
author_lname
from books
where author_lname = 'Eggers' or author_lname = 'Gaiman'
select
title,
released_year
from books
where released_year between 2005 and 2016
Função Cast
Imaginemos que temos uma data numa string e por algum motivo queremos que seja lida como uma data. Para isso utilizamos a função CAST:
select cast('2021-03-30' as datetime)
Comentários
Enviar um comentário