Skip to content
Advertisement

What is the syntax of array literal in H2 db?

I need to write an insert query where one value is an array of 3 elements. I’ve tried to do it like this: The sintax I’ve used for ‘col’ value is valid array literal in PostrgreSQL but H2 treats it as a single value of the array but not as an array with 3 elements. Table DDL: Answer Based on

Using a MIN MAX query over a DISTINCT one in MySQL?

With my new job, I am needing to use SQL more and more. As I need to remove duplicate columns I thought that using a DISTINCT statement would be best. However, I was indicated that a MIN MAX statement might be more suited. As I am still fairly new to SQL I was wondering if I could get some advice

SQL Month YTD and prior YTD data

I am trying to write a query to return Month-To-Date data for the Current Year, and also the Previous Year. Meaning I need data from 2017-07-01 to 2017-07-26 and also 2016-07-01 to 2016-07-26. However, my query currently returns data from 2017-07-01 to 2017-07-26 (correctly) but also returns data from 2016-07-01 to 2016-07-31 (incorrectly). How can I have the data for

Unique constraint keys not invoked when a field is NULL

I have a table named AQI, with the following column Only one unique value of date, pollutant_code, source_id and time are able to exist, so I defined a unique constraint source_code_time_uq. And the upsert query like The upsert method work normally when all the field available, but when I put NULL in the time column (in an attempt to make

Advertisement