当前位置:网站首页>Kingbasees SQL language reference manual of Jincang database (8. Function (2))

Kingbasees SQL language reference manual of Jincang database (8. Function (2))

2022-07-23 10:25:00 Thousands of sails passed by the side of the sunken boat_

8.21. ABBREV

usage :

abbrev({inet | cidr})

function :

Abbreviation display format text

Example :

abbrev(inet '10.1.0.0/16')

abbrev(cidr '10.1.0.0/16')

8.22. ABS

usage :

abs (n)

function :

ABS return n The absolute value of .

This function takes any numeric data type or any non numeric data type that can be implicitly converted to a numeric data type as a parameter . This function returns the same data type as the numeric data type of the parameter .

Example :

The following example returns -10 The absolute value of :

SELECT abs(-10);

8.23. ACOS

usage :

acos(n)

function :

ACOS return n The arccosine of . Parameters n Must be in -1 To 1 Within the scope of , And the function returns a value in 0 To pi Values in range , In radians .

This function takes any numeric data type or any non numeric data type that can be implicitly converted to a numeric data type as a parameter . If the parameter is BINARY_FLOAT, Then the function returns BINARY_DOUBLE. otherwise , Function returns the same numeric data type as the parameter .

Example :

The following example returns 0.5 The arccosine of :

SELECT acos('0.5');

8.24. ACOSH

usage :

acosh(n)

function :

ACOS return n The anti hyperbolic cosine of .

Example :

The following example returns 3 The anti hyperbolic cosine of :

SELECT acosh(float8 '3');

8.25. ADD_MONTHS

usage :

ADD_MONTHS(expr1  date / Time type , expr2 INT)

function :

return expr1 add expr2 Date time value of months .

  1. expr1 The data type is date / Time type (DATE、TIMESTAMP and TIMESTAMPTZ) Or it can be converted to date / Data type of time type . Enter the date / The time format string is automatically converted to TIMESTAMP.

  2. expr2 The data type is INT type .

Input TIMESTAMP and TIMESTAMPTZ When to return to TIMESTAMP. Input DATE When to return to DATE.

Example :

 Patients with a :
select add_months(date'2012-1-20',-1) AS RESULT;



 Example 2 :
select add_months(timestamp'2012-1-31 10:00:00',-20)  AS RESULT;




 Example 3 :
select add_months('20120101',12)  AS RESULT;

8.26. AGE

usage :

age(timestamp, timestamp)

age(timestamp)

function :

Subtract the parameter to generate a year 、 The month does not contain the formatted result of the day . Subtract... When there is only one parameter  current_date ( Midnight ).

Example :

SELECT age(timestamptz '2013-07-01 12:00:00', timestamptz '2011-03-01 12:00:00');

8.27. APPENDCHILDXML

usage :

appendchildxml(xml_instance xml,  xpath text , value_expr xml)
appendchildxml(xml_instance xml,  xpath text , value_expr xml,namespace _text)

function :

function appendchildxml take ``value_expr`` The value provided is used as ``xpath`` The child nodes of the node are appended to ``xml_instance`` in . If successful, the appended ``xml_instance`` data , Failure returns ERROR. Before using this function, you need to create kdb_utils_function Expand .

Example :

SELECT appendchildxml('<test><value></value><value></value></test>', '/test/value', XMLPARSE(CONTENT '<name>newnode</name>'));

8.28. ARRAY_AGG

usage :

array_agg(expression)

function :

When the parameter is of non array type , array_agg  Enter the value ( Include null value ) Connect to an array , Return an array of parameter types . When the parameter is array type ,array_agg  String the input array into a higher dimensional array , And return an array with the same parameter data type . The input array must have the same dimension , And cannot be empty or NULL.

Example :

SELECT array_agg(array[i, nullif(i, 3), i+1]) from generate_series(1,4) g(i);

8.29. ARRAY_APPEND

usage :

array_append(anyarray, anyelement)

function :

Directed array  anyarray  End append element  anyelement

Example :

SELECT array_append( ARRAY[1,2], 3);

8.30. ARRAY_CAT

usage :

array_append(anyarray1, anyarray2)

function :

Concatenate two arrays

Example :

SELECT array_cat( ARRAY[1,2], ARRAY[3,4]);

8.31. ARRAY_DIMS

usage :

array_dims(anyarray)

function :

Returns the text representation of the array dimension

Example :

SELECT array_dims( ARRAY[[1,2,3], [4,5,6]]);

8.32. ARRAY_FILL

usage :

array_fill(anyelement, int[], int[])

function :

Returns an array initialized with the specified value and dimension .

Example :

SELECT array_fill( 7, ARRAY[3], ARRAY[2]);

8.33. ARRAY_LENGTH

usage :

array_length(anyarray,int)

function :

Returns the length of the specified dimension of the array .

Example :

SELECT array_length( array[1,2,3,4], 1);

8.34. ARRAY_LOWER

usage :

array_lower(anyarray, int)

function :

Returns the lower bound of the specified dimension of the array

Example :

SELECT array_lower( array[1,2,3,4], 1);

8.35. ARRAY_NDIMS

usage :

array_ndims(anyarray)

function :

Returns the number of array dimensions

Example :

SELECT array_ndims( ARRAY[[1,2,3], [4,5,6]]);

8.36. ARRAY_POSITION

usage :

array_position(anyarray, anyelement[, int])

function :

Return to the array  anyelement  First occurrence of subscript , If the third parameter of the function specifies , Then search from the subscript specified by the third parameter .

Example :

SELECT array_position( ARRAY['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'], 'mon');

8.37. ARRAY_POSITIONS

usage :

array_positions(anyarray, anyelement)

function :

Returns an array of  anyarray  It appears that  anyelement  An array of subscripts of .

Example :

SELECT array_positions( ARRAY['A', 'A', 'B', 'A'], 'A');

8.38. ARRAY_PREPEND

usage :

array_prepend(anyelement, anyarray)

function :

Insert an element into the head of the array

Example :

SELECT array_prepend( 1, ARRAY[2,3]);

8.39. ARRAY_REMOVE

usage :

array_remove(anyarray, anyelement)

function :

From an array  anyarray  The value removed from is  anyelement  The elements of

Example :

SELECT array_remove( ARRAY[1,2,3,2], 2);

8.40. ARRAY_REPLACE

usage :

array_replace(anyarray, anyelement1, anyelement2)

function :

Will array  anyarray  The median is anyelement1 The element of is replaced by anyelement1.

Example :

SELECT array_replace( ARRAY[1,2,5,4], 5, 3);

8.41. ARRAY_TO_JSON

usage :

array_to_json(anyarray [, pretty_bool])

function :

Put the array  anyarray  As json Array return , A multidimensional array will become an array json Array . If  pretty_bool  Set to true , Line breaks will be added between array dimensions .

Example :

SELECT array_to_json('{
    {1,5},{99,100}}'::int[],true);

8.42. ARRAY_TO_STRING

usage :

array_lower(anyarray, int)

function :

Connect the array elements with the specified delimiter and an optional empty string

Example :

SELECT array_to_string( ARRAY[1, 2, 3, NULL, 5],',', '*');

8.43. ARRAY_TO_TSVECTOR

usage :

array_to_tsvector(text[])

function :

One of the text search functions , Convert the word bit array into tsvector.

Example :

SELECT array_to_tsvector('{fat,cat,rat}'::text[]);

8.44. ARRAY_UPPER

usage :

array_upper(anyarray, int)

function :

Returns the upper bound of the specified dimension of the array

Example :

SELECT array_upper( ARRAY[1,8,3,7], 1);

8.45. ASIN

usage :

asin(n)

function :

ASIN return n The inverse sine of . Parameters n Must be in -1 To 1 Within the scope of , The value returned by the function is -pi /2 To pi /2 Within the scope of , In radians .

This function takes any numeric data type or any non numeric data type that can be implicitly converted to a numeric data type as a parameter . If the parameter is BINARY_FLOAT, Then the function returns BINARY_DOUBLE. otherwise , Function returns the same numeric data type as the parameter .

Example :

The following example returns 0.5 The inverse sine of :

SELECT ASIN(0.5);

8.46. ASINH

usage :

asinh(n)

function :

ASINH return n The anti hyperbolic sine of .

Example :

The following example returns 0.5 The inverse sine of :

SELECT asinh(2);

8.47. ATAN

usage :

atan(n)

function :

ATAN return n It's all right . Parameters n It can be in an unbounded range , And back to - pi /2 To pi /2 Values in range , In radians .

This function takes any numeric data type or any non numeric data type that can be implicitly converted to a numeric data type as a parameter . If the parameter is BINARY_FLOAT, Then the function returns BINARY_DOUBLE. otherwise , Function returns the same numeric data type as the parameter .

Example :  The following example returns 0.5 It's all right :

SELECT ATAN(0.5) ;

8.48. ATAN2

usage :

atan2(n1, n2)

function :

ATAN2 return n1 and n2 It's all right . Parameters n1 It can be in an unbounded range , And back to -pi To pi Values in range , Depending on n1 and n2 The symbol of , In radians .

This function takes any numeric data type or any non numeric data type that can be implicitly converted to a numeric data type as a parameter . If any parameter is BINARY_FLOATor BINARY_DOUBLE, Then the function returns BINARY_DOUBLE. Otherwise, the function returns NUMBER.

Example :

The following example returns 1 and 2 It's all right :

SELECT atan2(1,2);

8.49. ATANH

usage :

atanh(n)

function :

ATANh return n The inverse hyperbolic tangent of .

Example :

The following example returns 0.2 The inverse hyperbolic tangent of :

SELECT atanh(0.2);

8.50. AVG

usage :

avg(expression)

function :

AVG return expr Average value .

This function takes any numeric data type or any non numeric data type that can be implicitly converted to a numeric data type as a parameter . This function returns the same data type as the numeric data type of the parameter .

Example :

The following example calculates students Average grades of all students in the table (score):

SELECT avg(score) from students;
原网站

版权声明
本文为[Thousands of sails passed by the side of the sunken boat_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/204/202207230335356049.html