-
Notifications
You must be signed in to change notification settings - Fork 0
/
Q5_Create_Views.sql
48 lines (39 loc) · 1.23 KB
/
Q5_Create_Views.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
USE MAGAZIN
GO
-- Vedere care contine produsele de pe o anumita comanda
/*
CREATE VIEW view_Produs_Comanda AS
SELECT DISTINCT
pr.Id_Produs,
pr.Nume_Produs,
pr.Pret,
dc.Denumire,
dc.Discount,
co.Numar_Comanda
FROM PRODUS pr, DETALII_COMANDA dc, COMANDA co
WHERE (dc.Id_Produs=pr.Id_Produs) AND (dc.Id_Comanda=co.Id_Comanda)
GO
*/
-- Vedere care contine produsele comandate de anumiti clienti
/*
CREATE VIEW view_Produse_Clienti AS
SELECT DISTINCT
pr.Id_Produs,
pr.Nume_Produs,
dc.Denumire,
co.Numar_Comanda,
cl.Nume,
cl.Prenume
FROM PRODUS pr, DETALII_COMANDA dc, COMANDA co, CLIENT cl
WHERE (dc.Id_Produs=pr.Id_Produs) AND (dc.Id_Comanda=co.Id_Comanda) AND (co.Id_Client=cl.Id_Client)
GO
*/
-- Vedere care contine produsele platite intr-un anumit mod (cash/cheque)
/*
CREATE VIEW view_Produse_Plata AS
SELECT
PL.Mod_plata, PR.Id_Produs, RTRIM(PR.Nume_Produs+' '+PR.Pret) Client
FROM PRODUS PR, DETALII_COMANDA DC, COMANDA CO, PLATA PL
WHERE (DC.Id_Produs=PR.Id_Produs) AND (DC.Id_Comanda=DC.Id_Comanda) AND (CO.Id_Plata=PL.Id_Plata)
GO
*/