SQLHUB Telegram 2041
💡 SQL: поиск уникальных значений с COUNT(DISTINCT)

Хотите посчитать количество уникальных элементов по каждому пользователю?
Не нужно подзапросов — используйте COUNT(DISTINCT ...) прямо в выборке.


SELECT
user_id,
COUNT(DISTINCT product_id) AS unique_products,
COUNT(DISTINCT category) AS unique_categories
FROM purchases
GROUP BY user_id;


🔎 В одном запросе можно узнать, сколько разных товаров и категорий купил каждый пользователь.
Это упрощает аналитику и заменяет сложные вложенные запросы.

@sqlhub
👍268🔥7



tgoop.com/sqlhub/2041
Create:
Last Update:

💡 SQL: поиск уникальных значений с COUNT(DISTINCT)

Хотите посчитать количество уникальных элементов по каждому пользователю?
Не нужно подзапросов — используйте COUNT(DISTINCT ...) прямо в выборке.


SELECT
user_id,
COUNT(DISTINCT product_id) AS unique_products,
COUNT(DISTINCT category) AS unique_categories
FROM purchases
GROUP BY user_id;


🔎 В одном запросе можно узнать, сколько разных товаров и категорий купил каждый пользователь.
Это упрощает аналитику и заменяет сложные вложенные запросы.

@sqlhub

BY Data Science. SQL hub


Share with your friend now:
tgoop.com/sqlhub/2041

View MORE
Open in Telegram


Telegram News

Date: |

During the meeting with TSE Minister Edson Fachin, Perekopsky also mentioned the TSE channel on the platform as one of the firm's key success stories. Launched as part of the company's commitments to tackle the spread of fake news in Brazil, the verified channel has attracted more than 184,000 members in less than a month. Healing through screaming therapy Earlier, crypto enthusiasts had created a self-described “meme app” dubbed “gm” app wherein users would greet each other with “gm” or “good morning” messages. However, in September 2021, the gm app was down after a hacker reportedly gained access to the user data. Telegram Channels requirements & features While some crypto traders move toward screaming as a coping mechanism, many mental health experts have argued that “scream therapy” is pseudoscience. Scientific research or no, it obviously feels good.
from us


Telegram Data Science. SQL hub
FROM American