Skip to content

Commit 14866c3

Browse files
authored
Merge pull request #3 from novy400/add-aggregate-functions-snippets
Add aggregate functions snippets
2 parents b6fcbc1 + 0a9dff4 commit 14866c3

File tree

2 files changed

+205
-3
lines changed

2 files changed

+205
-3
lines changed

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
"Other"
1818
],
1919
"publisher": "halcyontechltd",
20-
"author": {
21-
"name": "Halcyon-Tech, Liam Allan"
22-
},
20+
"author": {
21+
"name": "Halcyon-Tech, Liam Allan"
22+
},
2323
"repository": {
2424
"url": "https://github.com/halcyon-tech/vscode-db2i"
2525
},
@@ -39,6 +39,10 @@
3939
{
4040
"language": "sql",
4141
"path": "./src/language/snippets/variables.code-snippets"
42+
},
43+
{
44+
"language": "sql",
45+
"path": "./src/language/snippets/aggregates.code-snippets"
4246
}
4347
],
4448
"configuration": {
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
// https://www.ibm.com/docs/en/i/7.3?topic=functions-aggregate
2+
{
3+
"array_agg": {
4+
"prefix": "array_agg",
5+
"body": "array_agg(${1:expression} ORDER BY ${2:sort-key-expression} ${3|ASC,DESC|})",
6+
"description": "The ARRAY_AGG function aggregates a set of elements into an array."
7+
},
8+
"avg": {
9+
"prefix": "avg",
10+
"body": "avg(${1|ALL,DISTINCT|} ${2:numeric-expression})",
11+
"description": "The AVG function returns the average of a set of numbers."
12+
},
13+
"correlation": {
14+
"prefix": "correlation",
15+
"body": "correlation(${1:expression}, ${2:expression})",
16+
"description": "The CORRELATION function returns the coefficient of correlation of a set of number pairs."
17+
},
18+
"corr": {
19+
"prefix": "corr",
20+
"body": "corr(${1:expression}, ${2:expression})",
21+
"description": "The CORR function returns the coefficient of correlation of a set of number pairs."
22+
},
23+
"count": {
24+
"prefix": "count",
25+
"body": "count(${1|ALL,DISTINCT|} ${2:expression})",
26+
"description": "The COUNT function returns the number of rows or values in a set of rows or values."
27+
},
28+
"count_big": {
29+
"prefix": "count_big",
30+
"body": "count_big(${1|ALL,DISTINCT|} ${2:expression})",
31+
"description": "The COUNT_BIG function returns the number of rows or values in a set of rows or values. It is similar to COUNT except that the result can be greater than the maximum value of integer."
32+
},
33+
"covariance": {
34+
"prefix": "covariance",
35+
"body": "covariance(${1:expression}, ${2:expression})",
36+
"description": "The COVARIANCE function returns the (population) covariance of a set of number pairs."
37+
},
38+
"covar": {
39+
"prefix": "covar",
40+
"body": "covar(${1:expression}, ${2:expression})",
41+
"description": "The COVAR function returns the (population) covariance of a set of number pairs."
42+
},
43+
"covariance_samp": {
44+
"prefix": "covariance_samp",
45+
"body": "covariance_samp(${1:expression}, ${2:expression})",
46+
"description": "The COVARIANCE_SAMP function returns the unbiased sample covariance (n-1) of a set of number pairs."
47+
},
48+
"covar_samp": {
49+
"prefix": "covar_samp",
50+
"body": "covar_samp(${1:expression}, ${2:expression})",
51+
"description": "The COVAR_SAMP function returns the unbiased sample covariance (n-1) of a set of number pairs."
52+
},
53+
"grouping": {
54+
"prefix": "grouping",
55+
"body": "grouping(${1:expression})",
56+
"description": "Used in conjunction with grouping-sets and super-groups, the GROUPING aggregate function returns a value that indicates whether a row returned in a GROUP BY answer set is a row generated by a grouping set that excludes the column represented by expression."
57+
},
58+
"json_arrayagg": {
59+
"prefix": "json_arrayagg",
60+
"body": "json_arrayagg(${1:json-expression})",
61+
"description": "The JSON_ARRAYAGG function returns a JSON array containing an array element for each value in a set of JSON or SQL values."
62+
},
63+
"json_objectagg": {
64+
"prefix": "json_objectagg",
65+
"body": "json_objectagg( key ${1:key-name-expression} value ${2:json-expression})",
66+
"description": "The JSON_OBJECTAGG function returns a JSON object containing a key:value pair for each specific key and value in a set of SQL values."
67+
},
68+
"listagg": {
69+
"prefix": "listagg",
70+
"body": "listagg(${1|ALL,DISTINCT|} ${2:string-expression}, ${3:separator-expression})",
71+
"description": "The LISTAGG function aggregates a set of string elements into one string by concatenating the strings. Optionally, a separator string can be provided which is inserted between contiguous input strings."
72+
},
73+
"max (aggregate)": {
74+
"prefix": "max",
75+
"body": "max(${1|ALL,DISTINCT|} ${2:expression})",
76+
"description": "The MAX aggregate function returns the maximum value in a set of values in a group."
77+
},
78+
"median": {
79+
"prefix": "median",
80+
"body": "median(${1:numeric-expression})",
81+
"description": "The MEDIAN function returns the median of a set of numbers."
82+
},
83+
"min (aggregate)": {
84+
"prefix": "min",
85+
"body": "min(${1|ALL,DISTINCT|} ${2:expression})",
86+
"description": "The MIN aggregate function returns the minimum value in a set of values in a group."
87+
},
88+
"percentile_cont": {
89+
"prefix": "percentile_cont",
90+
"body": "percentile_cont(${1:percentile-expression}) WITHIN GROUP (ORDER BY ${2:sort-expression})",
91+
"description": "The PERCENTILE_CONT function returns the value that corresponds to the specified percentile given a sort specification by using a continuous distribution model."
92+
},
93+
"percentile_disc": {
94+
"prefix": "percentile_disc",
95+
"body": "percentile_disc(${1:percentile-expression}) WITHIN GROUP (ORDER BY ${2:sort-expression})",
96+
"description": "The PERCENTILE_DISC function returns the value that corresponds to the specified percentile given a sort specification by using a discrete distribution model."
97+
},
98+
"regr_avgx": {
99+
"prefix": "regr_avgx",
100+
"body": "regr_avgx(${1:y-expression}, ${2:x-expression})",
101+
"description": "The REGR_AVGX functions return quantities that can be used to compute various diagnostic statistics needed for the evaluation of the quality and statistical validity of the regression model."
102+
},
103+
"regr_avgy": {
104+
"prefix": "regr_avgy",
105+
"body": "regr_avgy(${1:y-expression}, ${2:x-expression})",
106+
"description": "The REGR_AVGY functions return quantities that can be used to compute various diagnostic statistics needed for the evaluation of the quality and statistical validity of the regression model."
107+
},
108+
"regr_sxx": {
109+
"prefix": "regr_sxx",
110+
"body": "regr_sxx(${1:y-expression}, ${2:x-expression})",
111+
"description": "The REGR_SXX functions return quantities that can be used to compute various diagnostic statistics needed for the evaluation of the quality and statistical validity of the regression model."
112+
},
113+
"regr_sxy": {
114+
"prefix": "regr_sxy",
115+
"body": "regr_sxy(${1:y-expression}, ${2:x-expression})",
116+
"description": "The REGR_SXY functions return quantities that can be used to compute various diagnostic statistics needed for the evaluation of the quality and statistical validity of the regression model."
117+
},
118+
"regr_syy": {
119+
"prefix": "regr_syy",
120+
"body": "regr_syy(${1:y-expression}, ${2:x-expression})",
121+
"description": "The REGR_SYY functions return quantities that can be used to compute various diagnostic statistics needed for the evaluation of the quality and statistical validity of the regression model."
122+
},
123+
"regr_count": {
124+
"prefix": "regr_count",
125+
"body": "regr_count(${1:y-expression}, ${2:x-expression})",
126+
"description": "The REGR_COUNT function returns the number of non-null number pairs used to fit the regression line."
127+
},
128+
"regr_intercept": {
129+
"prefix": "regr_intercept",
130+
"body": "regr_intercept(${1:y-expression}, ${2:x-expression})",
131+
"description": "The REGR_INTERCEPT function returns the y-intercept of the regression line (\"b\" in the equation y = a * x + b)."
132+
},
133+
"regr_r2": {
134+
"prefix": "regr_r2",
135+
"body": "regr_r2(${1:y-expression}, ${2:x-expression})",
136+
"description": "The REGR_R2 function returns the coefficient of determination (\"R-squared\" or \"goodness-of-fit\") for the regression."
137+
},
138+
"regr_slope": {
139+
"prefix": "regr_slope",
140+
"body": "regr_slope(${1:y-expression}, ${2:x-expression})",
141+
"description": "The REGR_SLOPE function returns the slope of the line (\"a\" in the equation y = a * x + b)."
142+
},
143+
"stddev_pop": {
144+
"prefix": "stddev_pop",
145+
"body": "stddev_pop(${1|ALL,DISTINCT|} ${2:numeric-expression})",
146+
"description": "The STDDEV_POP function returns the biased standard deviation (/n) of a set of numbers."
147+
},
148+
"stddev": {
149+
"prefix": "stddev",
150+
"body": "stddev(${1|ALL,DISTINCT|} ${2:numeric-expression})",
151+
"description": "The STDDEV function returns the biased standard deviation (/n) of a set of numbers."
152+
},
153+
"stddev_samp": {
154+
"prefix": "stddev_samp",
155+
"body": "stddev_samp(${1|ALL,DISTINCT|} ${2:numeric-expression})",
156+
"description": "The STDDEV_SAMP function returns the sample standard deviation (/n-1) of a set of numbers."
157+
},
158+
"sum": {
159+
"prefix": "sum",
160+
"body": "sum(${1|ALL,DISTINCT|} ${2:numeric-expression})",
161+
"description": "The SUM function returns the sum of a set of numbers."
162+
},
163+
"var_pop": {
164+
"prefix": "var_pop",
165+
"body": "var_pop(${1|ALL,DISTINCT|} ${2:numeric-expression})",
166+
"description": "The VAR_POP function returns the biased variance (/n) of a set of numbers."
167+
},
168+
"variance": {
169+
"prefix": "variance",
170+
"body": "variance(${1|ALL,DISTINCT|} ${2:numeric-expression})",
171+
"description": "The VARIANCE function returns the biased variance (/n) of a set of numbers."
172+
},
173+
"var": {
174+
"prefix": "var",
175+
"body": "var(${1|ALL,DISTINCT|} ${2:numeric-expression})",
176+
"description": "The VAR function returns the biased variance (/n) of a set of numbers."
177+
},
178+
"var_samp": {
179+
"prefix": "var_samp",
180+
"body": "var_samp(${1|ALL,DISTINCT|} ${2:numeric-expression})",
181+
"description": "The VAR_SAMP function returns the sample variance (/n-1) of a set of numbers."
182+
},
183+
"variance_samp": {
184+
"prefix": "variance_samp",
185+
"body": "variance_samp(${1|ALL,DISTINCT|} ${2:numeric-expression})",
186+
"description": "The VARIANCE_SAMP function returns the sample variance (/n-1) of a set of numbers."
187+
},
188+
"xmlagg": {
189+
"prefix": "xmlagg",
190+
"body": "xmlagg(${1:xml-expression} ORDER BY ${2:sort-key-expression} ${3|ASC,DESC|})",
191+
"description": "The XMLAGG function returns an XML sequence containing an item for each non-null value in a set of XML values."
192+
},
193+
"xmlgroup": {
194+
"prefix": "xmlgroup",
195+
"body": "xmlgroup(${1:expression+})",
196+
"description": "The XMLGROUP function returns an XML value that is a well-formed XML document."
197+
}
198+
}

0 commit comments

Comments
 (0)