TrabalhosGratuitos.com - Trabalhos, Monografias, Artigos, Exames, Resumos de livros, Dissertações
Pesquisar

Banco de Dados

Por:   •  1/11/2016  •  Trabalho acadêmico  •  327 Palavras (2 Páginas)  •  175 Visualizações

Página 1 de 2

FICA – Faculdades Integradas Camões
Curso: ADS/GTI 4ºPeríodo
Disciplina: Banco de Dados II
Professor: Rômulo Ferreira
Aluno: Luciano Araujo

Trabalhando com Funções que manipulam número, string e data/hora no MySQL

select idViagem, destinoViagem, custoViagem, custoViagem/kmPercViagem from Viagens;

update Viagens set custoViagem = custoViagem*1.058 where tipoViagem like 'Internacional';

select nomeViajante, dtPartidaViagem, dtRetornoViagem, destinoViagem from Viagens where kmPercViagem < 1000;

select nomeViajante, dtPartidaViagem, dtRetornoViagem, destinoViagem from Viagens where motViagem like 'Passeio' and tipoViagem like 'Nacional';

select nomeViajante, dtPartidaViagem, dtRetornoViagem, destinoViagem from Viagens where motViagem like 'Passeio' or tipoViagem like 'Internacional';

select nomeViajante, destinoViagem from Viagens where nomeViajante like '%o%';

select nomeViajante, destinoViagem from Viagens where nomeViajante not like 'Bianca';

select nomeViajante, destinoViagem from Viagens where left(nomeViajante, 1) like '^[a-d]' ;

select idViagem as 'Código', destinoViagem as 'Destino' , custoViagem as 'Custo', cast(custoViagem/kmPercViagem as decimal(3,2)) from Viagens;

select idViagem, destinoViagem, length(destinoViagem) as 'Quantidade' from Viagens;

select upper(nomeViajante) as 'Nome' , upper(destinoViagem) as 'Destino', upper(destinoViagem) as 'Quantidade' from Viagens;

select nomeViajante, destinoViagem, concat(upper(left(motViagem,3)),'-', upper(left(tipoViagem,3))) as 'Motivo/Tipo' from Viagens;

select nomeViajante, dtPartidaViagem, dtRetornoViagem, custoViagem, kmPercViagem from Viagens where length(destinoViagem)>8;

select nomeViajante, case month(dtPartidaViagem) when 1 then 'Janeiro' when 2 then 'Fevereiro' when 3 then 'Março' when 4 then 'Abril' when 5 then 'Maio' when 6 then 'Junho' when 7 then 'Julho' when 8 then 'Agosto' when 9 then 'Setembro' when 10 then 'Outubro' when 11 then 'Novembro' when 12 then 'Dezembro' end as PARTIDA, /*para mostrar o nome do mês EM PORTUGUÊS seria o mesmo código do anterior */date_format(dtRetornoViagem, '%M') as 'Retorno' from Viagens;

select nomeViajante, destinoViagem, datediff(dtRetornoViagem,dtPartidaViagem) as 'Qtde dias' from Viagens where tipoViagem like 'Nacional';                        

update Viagens set dtRetornoViagem = date_add(dtRetornoViagem, interval 20 day) where tipoViagem like 'Internacional';

update Viagens set dtRetornoViagem = date_sub(dtRetornoViagem, interval 2 day) where nomeViajante like 'Bianca';

select nomeViajante, destinoViagem, motViagem, tipoViagem, date_format(dtPartidaViagem, '%W') as 'Partida' , date_format(dtRetornoViagem, '%W') as Retorno from Viagens;

select nomeViajante, destinoViagem, datediff(dtPartidaViagem, now()/*Sendo que as viagens já aconteceram, aparecerão números negativos*/) as 'Faltam(dias)' from Viagens where tipoViagem like 'Internacional';

...

Baixar como (para membros premium)  txt (2.9 Kb)   pdf (54.1 Kb)   docx (5.4 Kb)  
Continuar por mais 1 página »
Disponível apenas no TrabalhosGratuitos.com