Skip to content

Tag: sql

How to order SQL query by largest string array sizes?

Background I’m quite new to SQL so apologies if I come off ignorant. After reading through some related threads I am still confused. I got the data from a Firestore export whose endpoint was a Google Cloud Storage bucket. I created a table from the bucket data in BigQuery. Question I want to order the q…

Excluding same type of transactions within 3 seconds

For example, a table is like below Type Time Stamp Result 1 2021-06-25 14:21:00 A 1 2021-06-25 14:21:03 B 1 2021-06-25 14:21:06 C 1 2021-06-25 14:23:00 D 2 2021-06-25 14:21:02 C 2 2021-06-25 14:21:06 C 2 2021-06-25 14:21:09 D 3 2021-06-25 14:21:06 E And the result I want is as below. If there are a series of …

Using where clause within a partition

I have huge pageview level table, where each session has multiple pageviews. Session -> Pageviews – 1 : M From the pageviews table, I need to consolidate the data into one row per session with meta data like FirstPageview, LastPageview, #ofvisitstoLogin Firstpageview is defined as the very first page…

Array to string with Django and MySQL

I need to design SQL query in html on Django I have an array in my table like : When I call this array in my page : I have : [‘aa’, ‘bb’, ‘cc’] What do I do if I want : a b c I tried with .split(‘,’) but I’ve already ‘[]’ I tried with for item …

Combine lead and lag function without overlap

I have this table: I need to get an output like this: I’ve tried a normal lead window function, but that would only show the first ‘Creation’ and not that last ‘Pending’ that I need. Answer Your table has N records (3 in the example provided) when query must return N + 1 (4); let…