Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
The db might look like this

MARKS1  MARKS2 TOTAL
 10     12      22

Thank you in advance

[edit]SHOUTING removed, Code block added - OriginalGriff[/edit]
Posted
Updated 22-Jan-16 8:13am
v2
Comments
[no name] 22-Jan-16 14:08pm    
You provided the column with data. That is ok. But what do you want exactly?
ZurdoDev 22-Jan-16 14:11pm    
Your question does not make any sense. Explain where you are stuck and what you need. And stop using all CAPS, it's considered shouting and rude.
OriginalGriff 22-Jan-16 14:13pm    
DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalization if you want to be taken seriously.
jgakenhe 22-Jan-16 14:31pm    
Not exactly sure what you are wanting but it sounds like you want a Computed Column.

Here is an example of a Computed Column: https://www.mssqltips.com/sqlservertip/2481/getting-creative-with-computed-columns-in-sql-server/

* Personally, I would not use them. I would do any computations in either my application or if that is not possible, then my SQL query.
Member 12001186 22-Jan-16 16:34pm    
If I understand correctly something like:

SELECT firstname, lastname, firstname+lastname as 'fullname' FROM dbo.Users;

You can use computed columns, functions etc. as well.

1 solution

Here you go
SQL
CREATE TABLE tblMarks(Mark1 INT,Mark2 INT,Total AS Mark1 + Mark2)

INSERT INTO tblMarks
SELECT 10,10

SELECT * FROM tblMarks


Result would be
Mark1 Mark2 Total
10 10 20

Hope this helps if yes then vote and accept the solution
Thanks - RDBurmon
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900