Integer division |
||||||||||||||||||||||||||||||||||||||||||
Newbies in A database management system (DBMS) by Microsoft Corporation. SQL(Structured Query Language) is a database computer language designed for the retrieval and management of data in relational database management systems (RDBMS), database schema creation and modification, and database object access control management.SQL Server sometimes fall in bewilderment when getting the results of queries like this Somebody (I suspect, they are users of MySQL or Oracle) expects the results in somewhat as
To resolve this bewilderment I shall tell, that operation "/" designates just the integer part of the result of dividing two integers (namely,
Modulo operation is designated as "%" in SQL Server:
As for some other DBMS.PostgreSQL behaves similarly SQL Server. MySQL has a special operator DIV for obtaining a quotient:
The remainder of division can be received also a la Pascal:
Oracle has not operator for getting quotient in general, so the division result
MOD function is used in Oracle for getting remainder of division:
At last, if the divider equals zero MySQL returns NULL, whereas other DBMS considered here return divide by zero error.Suggested exercises: 137 |