查询总结sql server 2005中不同列中的值

时间:2022-06-28 15:09:14

i have columns i.e. theory marks, pratical marks, student's Id ,course Id ,& subject Id i need to add up the vaules present in columns theory marks & practical marks in order to get the aggregate, i dont know how to add the column values though. I am using sql server 2005

我有即理论的痕迹,之实践的痕迹,学生的ID,课程ID列,与对象ID我需要添加了列理论标记和实际标记目前vaules为了得到总,我不知道如何添加列值虽然。我正在使用sql server 2005

please help

1 个解决方案

#1


assuming theory marks and practical marks are numerical data types

假设理论标记和实际标记是数值数据类型

SELECT
    student_id,
    course_id,
    subject_id,    
    SUM(theory_marks + practical_marks) AS overall_mark
FROM
    table
GROUP BY
    student_id, course_id, subject_id

#1


assuming theory marks and practical marks are numerical data types

假设理论标记和实际标记是数值数据类型

SELECT
    student_id,
    course_id,
    subject_id,    
    SUM(theory_marks + practical_marks) AS overall_mark
FROM
    table
GROUP BY
    student_id, course_id, subject_id