Kimossab

SIBD - S5.2

Mar 12th, 2015
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.44 KB | None | 0 0
  1. /*2 2.1*/
  2. SELECT NúmeroFactura, DataFactura, TotalFactura FROM Facturas WHERE DataFactura BETWEEN '2006-04-01' AND '2006-05-31'
  3. /*2 2.2*/
  4. SELECT Nome, Endereço + ' ' + CódigoPostal + ' ' + Localidade AS 'Endereço Completo' FROM Fornecedores
  5. /*2 2.3*/
  6. SELECT PNoneContacto, ÚNomeContacto, LEFT(PNoneContacto,1) + LEFT(ÚNomeContacto,1) AS 'Iniciais' FROM Fornecedores
  7. /*2 2.4*/
  8. SELECT PNoneContacto, ÚNomeContacto, LEFT(PNoneContacto,1) + LEFT(ÚNomeContacto,1) AS 'Iniciais' FROM Fornecedores WHERE LEFT(PNoneContacto,1) = 'A' AND (LEFT(ÚNomeContacto,1) = 'S' OR LEFT(ÚNomeContacto,1) = 'J')
  9. /*2 2.5*/
  10. SELECT DataFactura, GETDATE() AS 'Data Actual', DATEDIFF(DAY,DataFactura,GETDATE()) AS 'Idade, em dias, da factura', DATEADD(DAY,3,DataFactura) AS 'DataFactura + 3dias', DATEPART(weekday,DataFactura) AS 'dia da semana da DataFactura' FROM Facturas
  11. /*2 2.6*/
  12. SELECT TOP 25 PERCENT Fornecedor, TotalFactura FROM Facturas ORDER BY TotalFactura DESC
  13. /*2 2.7*/
  14. SELECT NúmeroFactura, DataFactura, TotalFactura AS 'TOTAL da Factura', Pagamento AS 'Montante Pago', Crédito AS 'Crédito obtidos', TotalFactura-Pagamento-Crédito AS 'Montante em dívida' FROM Facturas WHERE DataFactura < '2006-05-01' AND TotalFactura > 500 AND TotalFactura-Pagamento-Crédito > 0
  15. /*2 2.8*/
  16. SELECT NúmeroFactura, DataFactura, TotalFactura FROM Facturas WHERE DataVencimentoFactura > DATEADD(DAY,-30,GETDATE())
  17. /*2 2.9*/
  18. SELECT * FROM Facturas WHERE DataPagamento IS NOT NULL
Advertisement
Add Comment
Please, Sign In to add comment