How to add parameters in a SQL select query? string time = 2013-09-25 00:00:00; I wish to use the time variable in the below mentioned SQL query Select LastUpdated from Employee where LastUpdated &…
PostgreSQL string_agg, default value when no value found
I have a table like this: date number system_id 1 33.1 1 2 24.2 1 3 14.1 1 4 15.5 1 5 1113 1 1 4513 2 2 53….
Selecting and ordering by the top from each country
I am scoring events where there are 2 individuals from each country in an event, BUT only the top finisher from a country receives points. If a country finishes 1st and 2nd, the 2nd place is dropped …
Is it possible to improve the performance of this subquery?
For my application I have a topic table and a vote table. The vote options are -1, 0, and 1. I’m trying to find the amount of times each topic was voted -1 and 1. So to find out, I am doing many …
How do I generate an array containing the numbers 1 to n in Postgres
I’m hoping there exists something like this: > SELECT nrange(10) {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} Similar to the range function in languages like Python and Racket. Of course, if no such function …
How to know if an uncommitted transaction tries to insert a specific unique key into SQL
I’m writing a programm which inserts data to a MariaDB-Server and can be used by different people on the same time. The transactions take some time, so the following problem might occur: Person A …
Array operation on hive collect_set
I am working on hive on large dataset, I have table with colum array and the content of the colum is as follows. [“20190302Prod4” “20190303Prod1” “20190303Prod4” “20190304Prod4” “20190305Prod3” “…
Get NULL values [closed]
How would I get a NULL value as well in this query: SELECT x_month FROM end_months WHERE x_month = 201907 This shows the month because it exists but I also want to have another row if it doesnt …
Access Query mysteriously omitting records
I have an MS Access Contact & Correspondence database consisting of a “Contacts” table (Name, phone, email, etc.) and a “Calls” table (Contact, Incoming/Outgoing, Time, Medium, Notes, etc.). The …
Compute Averages/Stdevs for multiple columns in sql
I have a sql table with a handful of numeric columns, say my_field_1, my_field_2,…,my_field_n. I’d like to be able to view some aggregate statistics for each of these fields in a nice way. My …