Skip to content
Advertisement

Tag: aggregate-functions

Union of arrays as aggregate function

I have the following input: I want the following output: I am grouping by name. For each group, the count should be aggregated as the max and the options should be aggregated as the union. I am having troubles figuring out how do the the latter. Currently, I have this query: http://rextester.com/YTZ45626 I know this can be easily done by

Writing my own aggregate function in postgresql

I’ve never wriiten my own aggreagtes, only store procedures and I need some advice. I want to write a custom aggregate which is going to return maximum value of the integer rows and incerement it by 10. How can I do that? I tried this: but it didn’t work. Can someone help me out? I got the error: Honestly, I

Calculate Median with SQL (DB2)

I’m having issues calculating the median for my result set and could use some help. I need to provide the median, max, min, avg, and standard deviation. There are 222 rows which can be more or less and I’m not sure what I have so far is an accurate way of calculating the median. Here is my query. Answer Here’s

Advertisement