A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.snowflake.com/en/sql-reference/functions/div0 below:

Website Navigation


DIV0 | Snowflake Documentation

DIV0

Performs division like the division operator (/), but returns 0 when the divisor is 0 (rather than reporting an error).

See also:

DIV0NULL

Syntax
DIV0( <dividend> , <divisor> )

Copy

Arguments
dividend

Numeric expression that evaluates to the value that you want to divide.

divisor

Numeric expression that evaluates to the value that you want to divide by.

Returns

The quotient. If the divisor is 0, the function returns 0.

Examples

As shown in the following example, the DIV0 function performs division like the division operator (/):

SELECT 1/2;
+----------+                                                                    
|      1/2 |
|----------|
| 0.500000 |
+----------+
SELECT DIV0(1, 2);
+------------+                                                                  
| DIV0(1, 2) |
|------------|
|   0.500000 |
+------------+

Copy

Unlike the division operator, DIV0 returns a 0 (rather than reporting an error) when the divisor is 0.

select 1/0;
100051 (22012): Division by zero

Copy

SELECT DIV0(1, 0);
+------------+                                                                  
| DIV0(1, 0) |
|------------|
|   0.000000 |
+------------+

Copy


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4