Let’s say I have a BigQuery table “events” (in reality this is a slow sub-query) that stores the count of events per day, by event type. There are many types of events and most of them don’t occur on …
Tag: sql
Dynamic Pivot of Email Addresses
I have tried to research this, and I am unable to find something quite like it. I have a table that may have entries added many times over as well as deleted. I have no idea how many columns I will …
Oracle SQL – create string by concatenating rows but does not exceed X number of characters
First I am trying to concatenate rows into string separated by comma. Second I do not want the string to be exceeded X number of character. If going to exceed then create another string from next row …
Count city and State from 2 different tables
I need to count the number of cities occurrences on 2 different tables. One Table is the Supplier table which has supplier_id, City and State. The second table is consumer with consumer id , City and …
group by with multiple columns and with condition
My query used to be SELECT PROVIDER, LEFT([START_TIME],13) as [HOUR], DEVICE_ID as BIKEID FROM table1 GROUP BY PROVIDER_NAME, DEVICE_ID, LEFT([START_TIME],13) and it was …
SQL REPLACE value based on position in string
I have a column where the values are all in this format ‘###-##-#-##-##-###-##-#’ I need to format all of the values to where the 2nd to last hyphen is replaced with a period ‘###-##-#-##-##-###.##-#’ …
How do I display two different sums of the same price with different parameters?
I need to get the SUM of 2 different Totals. One is just the Total and the second one is the Total that only includes products that are sold for less than $25. SELECT SUM(Price) AS Total FROM Sales (…
Can’t find a solution to a problem relating three tables and join operation
So, I am not able to solve the following problem. Three tables are given: tables I need to write a code using join so that all pairs friend pairs are listed with their full names. I only know that …
Find date difference in Oracle SQL based on condition
I have a table: table1 tran_id user_id start_date end_date 1 100 01-06-2018 18-06-2018 2 100 14-06-2018 14-06-2018 4 100 19-07-2018 …
How to build a query that pulls in a listing of employee ids for employees that have a value that occurred on a range of dates unique to employee?
I need to pull in the distinct employee IDs for any employee who had a corrective action with a list of corrective action type IDs within 180 days of their corrective action date. so if I have …