Val() and Sum() Function in MS Access

1. Val() Function :
val() function returns the number found in the string. In this function, it takes a string as a parameter and it will return the number in the string.

Note : This function will stop reading when the first non-numeric character comes.

Syntax :

Val(string) 

Example-1 :

SELECT Val("234geeksforgeeks12") 
AS ValNum;

Output –



ValNum
234

Example-2 :

SELECT Val("345") 
AS ValNum;

Output –

ValNum
345



2. Sum() Function :
Sum() function returns the sum of the set of value. In this function, the set of value is passed as a parameter and it will return the sum.

Note : Null value will be ignored by this function.

Syntax :

Sum(expression) 

Demo Database for example :

Table name : student

Student_id marks
101 89
102 67
103 40

Example-1 :

SELECT Sum(marks) AS Total 
From student;

Output –

Total
196

Example-2 :

SELECT Sum(marks) AS Total 
From student Where marks>50;

Output –

Total
156
My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.