我有一个学习问题,我难以理解。任何建议将非常感谢!只是一些基本的例子会让我朝着正确的方向前进。谢谢!
您收到2017年日历年期间输入数据库的学生测验信息列表的请求。 SQL查询将返回(a)学生的每个分数,(b)学生姓名,(c)测验所针对的类别,以及(d)将分数输入数据库时的记录。
答案 0 :(得分:0)
如果你仍然需要构建表并自己查询它,那就是这样的。您可以阅读注释并查看每种语法的作用
--CREATING the tables for the student information
create table quizinfo (
StudentId INT,
Name VARCHAR(500),
Score INT,
Class VARCHAR(500),
DateEntered smalldatetime,
Year INT
)
--Inserting data to the table
Insert into quizinfo values ('1', 'Ken Lee', '95', 'Math', '2017-05-
20', ' 2017')
Insert into quizinfo values ('2', 'Maria Chen', '100', 'Math', '2017-
05-20', '2017')
Insert into quizinfo values ('3', 'Sophia Reyes', '100', 'Math',
'2017-05-20', '2015')
--Selecting the data from the table where the year is only for 2017. The
--WHERE year = 2017 makes sure that it only picks up rows for 2017
SELECT Name, Score, Class, DateEntered, Year FROM quizinfo
WHERE year = '2017'