Bd fdsafdd

283 palavras 2 páginas
Funções Agregadas
São funções destinadas a obter resultados estatísticos sobre os registros do BD. AVG () Retorna a média aritmética de uma coluna. * Select AVG(Salario) From CADFUN * Select AVG(Distinct Salario) From CADFUN where DEPTO=3
Count Retorna o valor numerico inteiro de itens de um campo * Select count(filhos) From CADFUN
Max Retorna o maior valor de uma lista de valores Select max(Salario) From CADFUN Min Retorna o menor valor de uma lista de valores Select min(salario) From CADFUN Sum() Retorna o resultado de uma soma efetuada dos valores numéricos. * Select sum(salario) From CADFUN * Select sum(filhos) From CADFUN * Select sum(Salario) From CADFUN Where DEPTO = 2
Lower() Retorna em format minuscule uma String Select Lower(nome) From CADFUN
Upper() Retorna em forma maiúscula uma String Select UPPER(nome) From CADFUN

Agrupamento de resultados
Group By Agrupar resultados selecionados * Select DEPTO, COUNT(*) From CADFUN Group By DEPTO * Select Funcao, Count(*) From CADFUN Group By Fruncao * Select DEPTO, Sum(Salario) From CADFUN where DEPTO in(2,4) Group By DEPTO

SubQuery
Permite que seja feita uma pesquisa nos dados de uma tabela com base na existência de dados de outra tabela. IN/ NOT IN
Select * From Cargo Where COD_CARGO not in(Select cod_cargo From Funcionario)
Select * From Cargo Where COD_CARGO in (Select COD_CARGO From Funcionario) where COD_FUNC in (Select COD_FUNC From Dependente)
Sinal = Select * From Funcionario where SAL_FUNC = (Select Max(SAL_FUNC) From Funcionario)
Select * From Funcionario Where SAL_FUNC = (Select min(SAL_FUNC) From Funcionario where COD_FUNC in (Select COD_FUNC From Dependente))
Select * (Select Count(*) From Dependente Where COD_FUNC = Funcionario.CODFUNC) as QTDE_DEP From Funcionario.
UPDATE
Update Funcionario Set SAL_FUNC = SAL_FUNC * 1.1 Where COD_FUNC not in (Select COD_FUNC From Dependente)

Relacionados