Translate

lunes, 26 de septiembre de 2022

HOW-TO: SQL When to use USING instead of WHERE - SQL INTERMEDIATE

 Visto en Leetcode:

https://leetcode.com/

Problema: 

Dadas dos tablas con IDs de usuario queremos saber el nombre y el id de usuario con su id único.


Además queremos que aparezcan los nulls

Explicación:

En un primer momento lo más fácil sería pensar en usar un LEFT JOIN o un RIGHT JOIN

Sin embargo tenemos una claúsulas que nos puede ayudar a simplicar el código creada para estos casos concretos y sería USING

SELECT unique_id, name 

FROM Employees e

LEFT JOIN EmployeeUNI u ON e.id = u.id


Por qué usar USING en SQL

Using hace más legible el código y además nos ayuda a prevenir problemas más complejos.

Cómo usar USING en SQL

# Write your MySQL query statement below
SELECT unique_id,name
FROM Employees
LEFT JOIN EmployeeUNI
USING(id)

jueves, 8 de septiembre de 2022

Product Analytics: How to calculate retention and what does it means.

Understanding how well your business keeps customers engaged is crucial for success. Retention rate is a key metric to measure this success, but there's no one-size-fits-all approach. Depending of your goals and therefore your KPIs you can choose one of them to measure strategies or tactics.
Let's explore three common retention methodologies:

Classic Retention (Day N)

This method tracks the percentage of new users who return on a specific day. For example, if 3 out of 10 new users return on the second day, your Day 2 retention rate is 30%.

  • Benefits: Daily granularity, easy to explain and calculate.
  • Limitations: Sensitive to daily fluctuations.
  • Best for: Measuring the immediate impact of short-term campaigns or analyzing day-to-day retention trends.

Range Retention

This measures retention over a specific time interval, like a week or a month. For instance, if 9 out of 50 new users return within the first week, your first-week retention rate is 18%.

  • Benefits: Smooths out daily noise, easy to explain, good for long-term trend analysis.
  • Limitations: Less granular, longer lag time for results.
  • Best for: Monitoring overall business health and identifying weekly or monthly behavioral patterns.

Rolling Retention

This calculates the percentage of new users who return on or after a specific day. It provides a single metric representing long-term customer engagement.

  • Benefits: Fast to calculate, reflects overall stickiness.
  • Limitations: Open-ended, can be constantly changing, doesn't differentiate between frequent and infrequent users.
  • Best for: Supplementing other KPIs and understanding long-term customer relationships.

Choosing the Right Method

  • Classic Retention: Ideal for tracking short-term campaigns and daily engagement.
  • Range Retention: Best for monitoring overall business health and identifying behavioral patterns.
  • Rolling Retention: Useful for supplementing other metrics and understanding long-term customer relationships.