Database Research & Development

  • Home
  • NoSQL
    • NoSQL
    • Cassandra
  • Databases
    • Database Theory
    • Database Designing
    • SQL Server Coding Standards
    • SQL Server
    • PostgreSQL
    • MySQL
    • Greenplum
    • Linux
  • Interviews
    • SQL Server Interviews
    • MySQL Interviews
    • SQL Puzzles
  • DBA Scripts
    • SQL Server DBA Scripts
    • PostgreSQL DBA Scripts
    • MySQL DBA Scripts
    • Greenplum DBA Scripts
  • Home
  • Blog Archives !
  • (: Laugh@dbrnd :)
  • Contact Me !
sqlserverinterviews
Home 2015 October MySQL: Mathematical Calculation using Values, Parameters, Variables and Columns

MySQL: Mathematical Calculation using Values, Parameters, Variables and Columns

This article is half-done without your Comment! *** Please share your thoughts via Comment ***

In our application, we needed a different type of Mathematical Calculations using any values, variables, parameters and columns.

The RDBMS Product like: SQL Server, PostgreSQL and MySQL supports basic addition, subtraction, multiplication and division.

Also, RDBMS Products have different types of aggregate functions for calculating the SUM and Average.

Various Mathematical operations are available in the Database System, so we don’t require any dependency of Application because we can also tune and authenticate Mathematical operation at the database level.

Below is some sample Mathematical Operations for MySQL.

This sample based on static values. You can use any variable, parameters and column to perform the same kind of Mathematical operation.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
SELECT 8 + 8;
-- Ans: 16
 
SELECT 1 + 2 + 3 + 8 + 88 + 458;
-- Ans: 560
 
SELECT 2.5 + 4.5;
-- Ans: 7.0
 
SELECT .456987 + .000887452;
-- Ans: 0.457874452
 
SELECT 2.75 + -4.25;
-- Ans: -1.50
 
SELECT 16 - 8;
-- Ans: 8
 
SELECT 988 - 808;
-- Ans: 180
 
SELECT 9.5 - 8.1;
-- Ans: 1.4
 
SELECT 8.9 - 10.2;
-- Ans: -1.3
 
SELECT 8 - 4 - 1;
-- Ans: 3
 
SELECT .81 - .78;
-- Ans: 0.03
 
SELECT 10 * 8;
-- Ans: 80
 
SELECT 2 * -8;
-- Ans: -16
 
SELECT 3 * 7 * 8;
-- Ans: 168
 
SELECT 2.40 * 8;
-- Ans: 19.20
 
SELECT .7 * .8;
-- Ans: 0.56
 
SELECT 1/2;
-- Ans: 0.5000
 
SELECT 1.0/2.0;
-- Ans: 0.500000
 
SELECT 0/10;
-- Ans: 0.0000
 
SELECT 100/14;
-- Ans: 7.1429
 
SELECT -78.0/8.5;
-- Ans: -9.17647
 
SELECT .8/.1;
-- Ans: 8.00000
 
SELECT ((100 + 100) * .08);
-- Ans: 16.00
 
SELECT (10 - 8)/20;
-- Ans: 0.1000
 
SELECT (8.0 - 5.0)/3.0;
-- Ans: 1.00000
 
SELECT ((50 + 50) - (20 + 20));
-- Ans: 60

Oct 28, 2015Anvesh Patel
MySQL: Script to find Index Usage Statistics of a DatabaseDatabase Theory: What is Character Set and Collation
Anvesh Patel
Anvesh Patel

Database Engineer

October 28, 2015 MySQLAnvesh Patel, database, database research and development, dbrnd, Mathematical, MySQL, MySQL Command, MySQL Database Administrator, MySQL Database Designing, MySQL Database Programming, MySQL Error, MySQL Performance Tunning, MySQL Query, MySQL Tips and Tricks
About Me!

I'm Anvesh Patel, a Database Engineer certified by Oracle and IBM. I'm working as a Database Architect, Database Optimizer, Database Administrator, Database Developer. Providing the best articles and solutions for different problems in the best manner through my blogs is my passion. I have more than six years of experience with various RDBMS products like MSSQL Server, PostgreSQL, MySQL, Greenplum and currently learning and doing research on BIGData and NoSQL technology. -- Hyderabad, India.

About DBRND !

dbrnd

This is a personal blog (www.dbrnd.com).

Any views or opinions represented in this blog are personal and belong solely to the blog owner and do not represent those of people, institutions or organizations that the owner may or may not be associated with in professional or personal capacity, unless explicitly stated.

Feel free to challenge me, disagree with me, or tell me I’m completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or anonymous comments) - so keep it polite.

The content of this website is protected by copyright. No portion of this website may be copied or replicated in any form without the written consent of the website owner.

Recent Comments !
  • Anvesh Patel { Sure will do... } – May 27, 12:43 PM
  • Anvesh Patel { Great... } – May 27, 12:41 PM
  • Anvesh Patel { Great... } – May 27, 12:39 PM
  • Anvesh Patel { Great... } – May 27, 12:36 PM
  • Anvesh Patel { Great... } – May 27, 12:28 PM
  • Anvesh Patel { Great... } – May 27, 12:27 PM
  • Anvesh Patel { Great... } – May 27, 12:16 PM
  • Older »
Follow Me !
  • facebook
  • linkedin
  • twitter
  • youtube
  • google
  • flickr
© 2015 – 2019 All rights reserved. Database Research & Development (dbrnd.com)
Posting....