If the table have only two columns with employee name and their supervisor column and if it doesn’t have any other numeric or number column with employee_number or employee_id, then how the results can be produced. I’m not getting logic to show the results. Code for creating table in Mysql: ItR…
Calculating checksum in Big Query
I have a query in SAP HANA like below. I am calculating check_sum based on some column in the table Now I have created the same table in Big Query. I want to calculate check_sum in Big Query and get the same result as in SAP HANA I have tried like below It says TO_BINARY function is not available. I
How to get a count of records by minute using a datetime column
I have a table with columns below: Customer Time_Start A 01/20/2020 01:25:00 A 01/22/2020 14:15:00 A 01/20/2020 03:23:00 A 01/21/2020 20:37:00 I am trying to get a table that outputs a table by minute (including zeros) for a given day. i.e. Customer Time_Start Count A 01/20/2020 00:01:00 5 A 01/20/2020 00:02:…
Filtering unique values
Consider the following table: Column_A Column_B Column_C 1 UserA NULL 2 UserB NULL 3 UserC 1 4 UserA 1 5 UserB NULL 6 UserB 2 7 UserC 2 I’d like to return all rows (Column_A, Column_B, Column_C) such that either: Column_C is NULL, or for every unique value in Column_C, return the first row with Column_B…
How can we achieve the below output (PostgreSQL)
I need to calculate the Numerator and Denominator values for one metric called Payments% and the formulae for numerator is count(distinct id) where menuaction in (‘Billpayment’, Renewal’) Denominator formulae is count(distinct id) and I need the below columns in output using postgresql datab…
SQL query with loop to collect 14 day averages
I am a python user, new to SQL. I am trying to make a new table that is the average of the “NumberValue” column between two dates from “RecordDate” column, and slide that date range so that the new table has columns “average” that is the average of “NumberValue”…
Checking the Oracle SQL DECODE function result against 0
I’m looking at some old PL/SQL code and I have dozen of DECODE functions written like this: DECODE(value_1, value_2, 1, 0) = 0 Now, I know these DECODEs make comparison between value_1 and value_2 and they return true or false based on the outcome of comparison. But, for the love of coding, could someon…
Sum values in two different tables and join results keeping the columns
I have two tables: one with downtime and the other with productive time. I want to have a table like this But I am getting this In the result, I am getting twice the downtime of the sum for the report 04102021-1, but as can be seen in the second picture, the value is present only once. The script I
How to get percentage based on columns
so here is what I have: I have a hired column which is boolean values, population which is either US or EU values. Right now the freq divides the hired over the entire population which is like 5,000 values but I would like it to divide which are specifically US or EU values. Can anyone help me with doing this…
Hive regexp_extract numeric value from a string
I have a table as: I am trying to get the numeric values from the table. The expected output is A -> 123 / B -> 124 etc I am trying to do using regexp_extract Any suggestions please? Answer If the delimiters are fixed – ‘; ‘ between key-value pairs and ‘=’ between key and v…