I’m going to migrate data from PostgreSQL database to Yandex’s ClickHouse. One of the fields in a source table is of type JSON – called additional_data. So, PostgreSQL allows me to access json attributes during e.g. SELECT … queries with ->> and -> and so on. I need the same b…
Tag: sql
how parallel fetch data from MySQL with Sequel Pro in R
I want to fetch data from mysql with seqlpro in R but when I run the query it takes ages. here is my code : old_value
Counting Business Days PostgresSQL
I am attempting to do something like this: SELECT t.id, t.startdate, t.enddate, FOO FROM table Where “Foo” is some sql mumbo-jumbo to calculate the business days between startdate and …
Mapping two columns into one column in Athena
I have data in the Athena something like this: However, the table owner changed the provider to provider_new. Thus, after 2020-08-01 the provider returns to NULL. Here is my query: How can I map these two columns to one? Thanks in advance. Answer Do you want coalesce()? coalesce() returns the first non-null v…
Postgres Query to retrieve rows which has all the flag value as false
I have User to Role table with Many to Many relation. I need to retrieve all the roles which are not privileged(false) to any users. select distinct r.rolename,ur.privileged from pam.”role” …
Query help on sales transaction table
I have a table that contains transaction level sales data. I am trying to satisfy a reporting request as efficiently as possible which I don’t think I am succeeding at right now. Here is some test …
Why is my case statement not returning the value in my “else” clause?
I have this section of code and my ELSE is not working. It should return ‘UNKNOWN’ but I am still seeing NULLs in my results. What is going on? case when t2.NEURO_GRP_2 is not NULL …
Incorrect number of arguments for PROCEDURE… from C#
I am having trouble using parameters in a stored procedure. I believe I am not passing the parameters in correctly with the C#. My code is roughly equivalent to: public static string GetCustomer(…
Oracle sql adding custom column name as 1st row of the resultSet
How do I get the column name as the 1st row of the result set.I tried below but getting the error as shown below Answer I would recommend two changes to your query. Change UNION to UNION ALL. This way your union will not look for duplicates between the two parts of the union. Since the first part of your
SQL – Assign jobs to workers – Alternative to a loop?
In SQL Server 2019, I have a table of unassigned tasks, and another table of workers who are available to work on those tasks. My requirement is to assign the workers evenly over the available tasks …