Skip to content

Instantly share code, notes, and snippets.

View levelboy's full-sized avatar

Adrian Nistor levelboy

View GitHub Profile

Keybase proof

I hereby claim:

  • I am levelboy on github.
  • I am levelboy (https://keybase.io/levelboy) on keybase.
  • I have a public key ASAqlkNY7pa3U8mT96CaCCb01AR8qumD8tWl-jOsXY_Mrgo

To claim this, I am signing this object:

SELECT data.Id studentId, data.FirstName, data.LastName, min( grade.Grade ) grade
FROM StudentData data
INNER JOIN Grade grade ON grade.IdStudent = data.Id
INNER JOIN Student student ON student.Id = data.Id
WHERE grade.Grade <5
AND student.CurrentYear =2
GROUP BY studentId
select data.FirstName, data.LastName, data.Father from Student student
inner join StudentData data
on data.Id = student.Id
where student.CurrentYear=1
select course.Name as CourseName, course.Professor as ProfessorName, faculty.Dean as DeanName
from Faculty as faculty
inner join Specialty as specialty
on specialty.IdFaculty = faculty.Id
inner join Course as course
on course.IdSpecialty = specialty.Id
where faculty.Id = 1
@levelboy
levelboy / Ch 9 E 1
Last active November 19, 2015 13:49
select course.Name as CourseName, specialty.Name as SpecialtyName
from Course course
inner join Specialty specialty
on course.IdSpecialty = specialty.Id
where specialty.Id = (select IdSpecialty from Course group by IdSpecialty order by count(*) desc limit 1)
CREATE TABLE Faculty (
Id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
Name VARCHAR(50),
Address VARCHAR(60),
YearFounded YEAR,
Dean VARCHAR(50)
);
CREATE TABLE Specialty(
Id int not null primary key auto_increment,
SELECT c.Name, s.FirstName, s.LastName, g.Grade
FROM Grade g, StudentData s, Course c
WHERE g.IdStudent = s.Id and g.IdCourse = c.Id
order by g.IdCourse Asc, s.FirstName Asc, s.LastName Asc
select IdStudent, avg(Grade) as grade_sum into @best_student_id, @best_average from Grade group by IdStudent order by grade_sum desc limit 1;
select * from StudentData where Id = @best_student_id;
select IdCourse, count(*) as number_of_failures into @id_course, @occurences from Grade where Grade < 5 group by IdCourse order by number_of_failures desc limit 1;
select * from Course where Id = @id_course;
DELIMITER $$
// Trebuie sa facem o procedura. Se pare ca in mysql nu poti folosi loop-uri direct intr-un script. Am pus mai jos un script template pentru o procedura
DROP PROCEDURE IF EXISTS insert_grades$$
CREATE PROCEDURE insert_grades()
BEGIN
set @number_of_students = (select count(*) from StudentData);
set @number_of_courses = (select count(*) from Course);