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 …
object Object error in R Shiny SQLite App
I am trying to develop an R Shiny app with an SQLite Database. But I am facing this error while getting any data from the database. The error message is: Loading required package: shiny Attaching …
I’m looking for a pair of SQL functions (MS SQL Server) that will return the MAX or MIN of a list of dates
I’m looking for a pair of SQL functions that will return the MAX and MIN value of a list of dates (or, alternatively, the MAX and MIN of two dates – I can then stack the calls to handle the whole list)…