Skip to content
Advertisement

Tag: google-bigquery

Only return rows where Status Online is the only status is applicable (perhaps a coalesce function or qualify function)

ID Status Date 1 Online 2022-06-31 1 Offline 2022-07-28 2 Online 2022-08-01 3 Online 2022-07-03 3 Stationary 2022-07-05 4 Offline 2022-05-02 5 Online 2022-04-04 5 Online 2022-04-06 The output I’m looking for in SQL/BigQuery ID Status Date 2 Online 2022-08-01 5 Online 2022-04-04 5 Online 2022-04-06 So what SQL query I would want to return is the rows for ID

Fill Null Values with Last Previous Value and add 1 as a continuous integer for every value going forward – Big Query

I have these two columns in Big Query: budget_id and activity: budget_id activity region execution window 000507_Corporate 507 Corporate 2022 000508_AMERICAS 508 AMERICAS 2022Q2 NULL NULL c b NULL NULL c b The budget_id comes from a Google Sheet which is manually inputted by a stakeholder. I’m trying to change this that going forward, I can automate this myself. Everything

Count records based on a repeating field while returning other values

I have the following query and a sample output uid creation_date activity_date feature1 feature2 feature3 id1 date1 date1x asdf sfsdfd sdsdf id1 date1 date1x asdf fasaa asdas id1 date1 date1x asdf sfsdfd asdas id1 date1 date1x aadf afdsf adfad id2 date2 date2x aadf afdsd asdas id2 date2 date2x aadf adsfsdf sdsdf id2 date2 date2x asdas afdsf adfad id3 date3 date3x

Correct BigQuery SQL to get value from previous partition

I am trying to use a window function to get a value from the previous partition/window frame (rather than from some other row in the same partition). I don’t fully understand how I can do this but have tried various combinations of using: partition clause but with LAG() function omitting partition clause and using an ORDER BY + a RANGE

Advertisement