Vous êtes sur la page 1sur 5

Jurj Gheorghe Danut

E212A
Tema 3
Baze de Date

UPDATE:
1.Sa se mareasca Pretul cu 50 la toate produsele.

Constructii
Constructii
Constructii
Constructii
IT
IT
IT
IT

Ciocan
Cuie
Cleste
Patent
Calculator
Laptop
Stick
SSD

100
100
105
800
1000
1550
1180
1900

90
90
95
88
90
98
97
380

1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01

100
100
105
800
1000
1550
1180
1900

140
140
145
138
140
148
147
430

1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01

UPDATE Materiale
SET
Pret = Pret + 50

Constructii
Constructii
Constructii
Constructii
IT
IT
IT
IT

Ciocan
Cuie
Cleste
Patent
Calculator
Laptop
Stick
SSD

2.Sa se scada preturile mai mari de 140 cu 15%.

Constructii
Constructii
Constructii
Constructii
IT
IT
IT
IT

Ciocan
Cuie
Cleste
Patent
Calculator
Laptop
Stick
SSD

100
100
105
800
1000
1550
1180
1900

140
140
145
138
140
148
147
430

1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01

UPDATE Materiale
SET
Pret = 0.85*Pret
where Pret>140

Constructii
Constructii
Constructii
Constructii
IT
IT
IT
IT

Ciocan
Cuie
Cleste
Patent
Calculator
Laptop
Stick
SSD

100
100
105
800
1000
1550
1180
1900

140
140
123,25
138
140
125,8
124,950005
310,675018

DELETE:
1.Sa se stearga inregristrarile cu pretul mai mare de 140.

1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01

Constructii
Constructii
Constructii
Constructii
IT
IT
IT
IT

Ciocan
Cuie
Cleste
Patent
Calculator
Laptop
Stick
SSD

100
100
105
800
1000
1550
1180
1900

140
140
123,25
138
140
125,8
124,950005
310,675018

1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01

100
100
105
800
1000
1550
1180

140
140
123,25
138
140
125,8
124,950005

1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01

DELETE FROM Materiale


WHERE (Pret > 140)

Constructii
Constructii
Constructii
Constructii
IT
IT
IT

Ciocan
Cuie
Cleste
Patent
Calculator
Laptop
Stick

2. Sa se stearga inregistrarile Din Clasa IT care au o cantitate mai mare decat


1500 si un pret mai mare decat 120.

Constructii
Constructii
Constructii
Constructii

Ciocan
Cuie
Cleste
Patent

100
100
105
800

140
140
123,25
138

1995-01-01
1995-01-01
1995-01-01
1995-01-01

IT
IT
IT

Calculator
Laptop
Stick

1000
1550
1180

140
125,8
124,950005

1995-01-01
1995-01-01
1995-01-01

DELETE FROM Materiale


WHERE (Clasa = N'IT') AND (Cantitate > 1500) AND (Pret > 120)

Constructii
Constructii
Constructii
Constructii
IT
IT

Ciocan
Cuie
Cleste
Patent
Calculator
Stick

100
100
105
800
1000
1180

140
140
123,25
138
140
124,950005

1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01

MAKE TABLE:
1. Sa se creeze un alt tabel cu inregistrarile din Clasa IT care sa contina Clasa
, Numele si Pretul.

SELECT Clasa, Nume, Pret


INTO
IT
FROM
Materiale
WHERE (Clasa = N'IT')

IT
IT

Calculator
Stick

140
124,950005

2. ..... cu inregistrarile cu pretul mai mare decat 120 si cantitatea mai mare
decat 1000.

SELECT Clasa, Nume, Pret


INTO
IT
FROM
Materiale
WHERE (Pret>120) AND (Cantitate>1000)

IT

Stick

124,950005

INSERT INTO:
INSERT INTO Materiale
(Cantitate, Clasa, Nume)
VALUES (1200, N'IT', N'BOXE')

Constructii
Constructii
Constructii
Constructii
IT
IT
IT
NULL

Ciocan
Cuie
Cleste
Patent
Calculator
BOXE
Stick
NULL

100
100
105
800
1000
1200
1180
NULL

140
140
123,25
138
140
NULL
124,950005
NULL

INSERT INTO IT
(Pret, Clasa, Nume)
SELECT Pret, Clasa, Nume
FROM
Materiale
WHERE (Pret > 140)

IT
IT

Calculator
Stick

140
124,950005

1995-01-01
1995-01-01
1995-01-01
1995-01-01
1995-01-01
NULL
1995-01-01
NULL

Vous aimerez peut-être aussi