简体   繁体   中英

how to sum only a specific row in a table

i am having one table name student detail which containing following columns and data's

NAME   MARK2      MARK3      SID      MARK1  

Timmy  85         95         123        25


GSJD   75         95         25         69


FBKSD   88         75        27         96

i was trying to get sum the values of mark 1,mark2,mark3 for a specific row where mark1=96

SQL>

    SELECT mark1,
       mark2,
       mark3
FROM studentdetail
WHERE mark1=96(
  SELECT sum(mark1 +mark2+mark3)
  FROM studentdetail;

but its not working can you guys suggest me in this

在Mysql中,您可以这样:

select mark1,mark2,mark3,(mark1 +mark2+mark3) as Total from studentdetail where mark1=96; 
select (mark1+mark2+mark3) as mark_sum 
from studentdetail 
where mark1=96
SELECT mark1 + mark2 + mark3 AS total
FROM tbl_StudentDetail
WHERE mark = 96

用这个:

select mark1 + mark2 + mark3 as totalmarks from studentdetail where mark1 = 96;
select mark1,(mark1+mark2+mark3) as total from studentdetail where mark1=96

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM