fork download
  1. CREATE TABLE Students (
  2. student_name CHAR(50),
  3. direction_of_study CHAR(50),
  4. course INT,
  5. education_level CHAR(50),
  6. internship CHAR(50)
  7. );
  8.  
  9. CREATE TABLE Prac (
  10. direction_of_study CHAR(50),
  11. course INT,
  12. internship_type CHAR(50),
  13. internship_location CHAR(50)
  14. );
  15. INSERT INTO Students (student_name, direction_of_study, course, education_level, internship)
  16. VALUES
  17. ('Marat', 'IS', 2, 'bak', 'web'),
  18. ('Adam', 'VT', 2, 'bak', 'sysadmin'),
  19. ('Sam', 'IS', 1, 'mag', 'backend'),
  20. ('Marat', 'IS', 1, 'bak', 'frontend'),
  21. ('Simon', 'VT', 2, 'mag', 'sysadmin'),
  22. ('Marat', 'VT', 1, 'bak', 'frontend');
  23.  
  24. INSERT INTO Prac (direction_of_study, course, internship_type, internship_location)
  25. VALUES
  26. ('IS', 2, 'web', 'bank'),
  27. ('VT', 2, 'sysadmin', 'tech company'),
  28. ('IS', 1, 'backend', 'tech company'),
  29. ('IS', 1, 'frontend', 'tech company'),
  30. ('VT', 3, 'sysadmin', 'bank'),
  31. ('VT', 1, 'bak', 'frontend');
  32.  
  33. SELECT student_name
  34. FROM Students
  35. INNER JOIN Prac ON Students.direction_of_study = Prac.direction_of_study AND Students.course = Prac.course
  36. WHERE Students.direction_of_study = 'VT'
  37. AND Students.course = 2
  38. AND Prac.internship_location = 'tech company';
  39.  
  40.  
  41. SELECT DISTINCT internship_type, internship_location
  42. FROM Prac
  43. WHERE direction_of_study = 'IS';
  44.  
  45.  
  46. SELECT COUNT(DISTINCT internship_location) AS company_count
  47. FROM Prac;
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
Adam
Simon
web|bank
backend|tech company
frontend|tech company
3