Skip to content

Tag: sql

Daily User Retention for a month mySQL

I have log_event table and which has table as shown below: db<>fiddle I wanted Daily user retention(day-1) for Aug’18. Day-1 retention: Users who registered on day-0 and then opened app on day-1. For ex: In short users who registered on like 15th Aug 2018 and opened app on 16th Aug 2018 Answer You…

Get every unique pair combination of a column in SQL

Lets say I have given table: How do I JOIN / combine the table with itself so I get every possible unique pair combination of the first column: Answer You can do something like this. Cross JOIN is used for cross product

SQL Pivot in BigQuery

I have a SQL table with information about email campaigns that my company has created. Each line of the table is an action that a user has taken on a specific campaign: User ID Campaign Name Status 01 Campaign#1 opened 01 Campaign#1 clicked 01 Campaign#2 opened 02 Campaign#1 opened 02 Campaign#2 opened I want…

How insert if a row not already exists ? (query)

My tables : Wrong migration script : I try insert new row if FirstTable.label == Str Test isn’t already exists but i get an error : SQL Error [1064] [42000]: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ” at…