0% found this document useful (0 votes)
32 views2 pages

LAB3

The document creates two tables, Angajati and Sectii, inserts data into them, and performs various SELECT queries on the tables to retrieve data like names, salaries, minimum, maximum, average salaries, counts, sums of salaries grouped by section. It also joins the tables to find employees that meet certain criteria.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views2 pages

LAB3

The document creates two tables, Angajati and Sectii, inserts data into them, and performs various SELECT queries on the tables to retrieve data like names, salaries, minimum, maximum, average salaries, counts, sums of salaries grouped by section. It also joins the tables to find employees that meet certain criteria.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Laborator 3

CREATE TABLE Angajati(


AngajatiID INT NOT NULL,
Nume varchar(20),
Prenume varchar(20),
DataNasterii DATE NOT NULL,
Adresa varchar(50) NOT NULL,
Salariu NUMERIC NOT NULL,
SectieID INT NOT NULL ,
PRIMARY KEY (AngajatiID),
);
CREATE TABLE Sectii(
SectieID INT,
Nume varchar(10),
Buget INT,
);
INSERT INTO
Angajati([AngajatiID],[Nume],[Prenume],[DataNasterii],[Adresa],[Salariu],[SectieID])
VALUES
(1,'Ion','Petrescu','1989-09-14','Chisinau',40000,3),
(2,'Vasile','Virlan','1987-09-14','Timisoara',54690,2),
(3,'Larisa','Arici','2002-04-12','Iasi',94321,1);
GO
INSERT INTO Sectii([SectieID],[Nume],[Buget]) VALUES
(1,'Produse',189020),
(2,'Tehnica',192021),
(3,'Soft',837214);
GO
SELECT Nume,Prenume,DataNasterii,Adresa
FROM Angajati
ORDER BY Nume;
SELECT Nume,Prenume,DataNasterii
FROM Angajati
WHERE DataNasterii > '1970-03-1';
SELECT Nume,Buget
FROM Sectii;
SELECT Nume,Prenume
FROM Angajati
WHERE Adresa ='Iasi' or Adresa='Timisoare';
SELECT Nume,Prenume
FROM Angajati
WHERE Adresa ='Bucuresti' or Adresa='Ploiesti' or Adresa='Craiova';
SELECT COUNT(Salariu)
FROM Angajati;
SELECT MIN(Salariu)
FROM Angajati;
SELECT MAX(Salariu)
FROM Angajati;
SELECT SUM(Salariu) / COUNT(Salariu)
FROM Angajati;
SELECT MIN(Salariu)
FROM Angajati;
SELECT MIN(Salariu)
FROM Angajati
WHERE SectieID = 2;
SELECT MAX(Salariu)
FROM Angajati
WHERE SectieID = 1;
SELECT SUM(Salariu) / COUNT(Salariu)
FROM Angajati
WHERE SectieID = 3;
SELECT Nume,Prenume
FROM Angajati
WHERE Salariu > 63003;
SELECT Nume,Prenume
FROM Angajati
WHERE Salariu > 63003 and SectieID=3;
SELECT Nume
FROM Sectii
WHERE Nume = 'Soft';
SELECT SUM(Buget)
FROM Sectii;
SELECT * FROM Angajati;
SELECT * FROM Sectii;

You might also like