Skip to content

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…

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…