locked
SQL Help please? RRS feed

  • Question

  • User-1623844698 posted

    Hey so im having trouble getting SQL queries done. Are you able to help?

    The first question is;

    1. List title, start and end dates of all modules run in the ‘ICT - information and communication technologies’ course.

    For the SQL I have,

    SELECT ModuleTitle,StartDate,EndDate
    FROM Modules;
    WHERE CourseTitle='ICT'

    But im getting an error saying "Characters found after end of SQL statement" .. any ideas on how to resolve this?

    Second question is;

    2. List last name, post, and qualifications of all members of academic staff who are employed by the department of ‘Computing and Intelligent Systems’.

    For SQL I have,

    SELECT LastName, Post, Qualifications
    FROM Staff;
    WHERE DepartmentName = 'Computing and Intelligent Systems'

    and im getting the same error as the first one.

    The third question is;

    3. For each course with more than 6 students, list the course title and the number of students

    For SQL I have;

    SELECT CourseTitle, MatricultaionNumber
    FROM Course, Student
    WHERE MatricultaionNumber FROM Student > 6

    Im getting a syntax error (missing operator) in query expression MatricultaionNumber FROM Student > 6

    So yeah any help would be greatful! Im new at this stuff and i need to get it correct.

    Thanks :)

    Monday, April 2, 2012 10:10 AM

Answers

  • User306743125 posted

    For question 1 and 2....just remove the semicolon after the tabel name in your FROM clause

    and your 3rd question...you have 2 FROM clauses

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 2, 2012 10:15 AM
  • User306743125 posted

    Try something like this for your 3rd query

    SELECT C.CourseTitle, S.MatricultaionNumber
    FROM Course C
    RIGHT JOIN 
     (	
    	SELECT  MatricultaionNumber, COUNT(MatricultaionNumber) as NumberOfStudents
    	FROM Student 
    	GROUP BY CourseId 	
    ) S
    ON C.CourseId = S.CourseId
    WHERE S.NumberOfStudents > 6
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 2, 2012 10:22 AM

All replies

  • User306743125 posted

    For question 1 and 2....just remove the semicolon after the tabel name in your FROM clause

    and your 3rd question...you have 2 FROM clauses

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 2, 2012 10:15 AM
  • User306743125 posted

    Try something like this for your 3rd query

    SELECT C.CourseTitle, S.MatricultaionNumber
    FROM Course C
    RIGHT JOIN 
     (	
    	SELECT  MatricultaionNumber, COUNT(MatricultaionNumber) as NumberOfStudents
    	FROM Student 
    	GROUP BY CourseId 	
    ) S
    ON C.CourseId = S.CourseId
    WHERE S.NumberOfStudents > 6
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 2, 2012 10:22 AM
  • User-1623844698 posted

    Aw I cant even begin of how grateful I am for you help!

    THANK YOU!!! :)

    Monday, April 2, 2012 10:30 AM
  • User306743125 posted

    No problem.

    Kindly mark as the anwer, if it did resolve your issue, it'll also assist others.

    Cheers

    Monday, April 2, 2012 10:46 AM