Beginner needing help

50 views
Skip to first unread message

Michael Turnbull

unread,
Jan 6, 2022, 11:04:53 AM1/6/22
to Google Cloud SQL discuss
Hi all, I'm new to this forum and just starting out on my SQL learnings in Google's Big Query. 

I have an issue where I'm trying to show data in a particular way based on multiple events. I'll try my best to explain my problem, and hopefully someone can help or offer advice. Thanks in advance. 

Problem statement - 
I'm trying to show when a customer (who has a unique identifier) has a series of job references booked over a period of 3 weeks, in order to show volume of repeat jobs for that customer. 

Example of what I have (trying to layout how I have the data in rows and columns)

Row 1 - (Column 1) = Week 1, (Column 2) = Customer 123, (Column 3) = Job ref 123

Row 2 - (Column 1) = Week 3, (Column 2) = Customer 123, (Column 3) = Job ref 345

I'd like to be able to simplify this view and show that over a 3 week period, that Customer 123 has had a repeat job ref against their unique customer number. 

I'd like it to almost show something like the below 

Row 1 - (Column 1) = Week of initial job, (Column 2) = Customer 123, Column 3 = count of first job in week 1, (Column 4) = Count of any repeat jobs in the weeks after week 1 occurred. 

Hopefully that makes sense, and this is my first time posting, so any further info needed then please ask. 

Thanks in advance for any help relating to my issue. 

wokmou

unread,
Jan 6, 2022, 5:06:43 PM1/6/22
to Google Cloud SQL discuss
Aggregate Functions[1] will be a good start to help you summarizes the rows of a group into a single value. They return a single result row based on groups of rows, rather than on single rows.
[1] https://cloud.google.com/bigquery/docs/reference/standard-sql/aggregate_functions

Larry koch

unread,
Jan 27, 2022, 12:28:12 PM1/27/22
to Google Cloud SQL discuss
  I appreciate you sharing this. It was very helpful for my first project on Karl Jacobs shirts.

john michell

unread,
Feb 12, 2022, 4:44:08 PM2/12/22
to Google Cloud SQL discuss
I appreciate you sharing such valuable information. I am facing the same problem with georgenotfound merchandise. But this solution is really helpful.
Reply all
Reply to author
Forward
0 new messages