MySQL 8 has got the window functions! Therefore, you can write your query in it like this:
SELECT username,
count(sentSmsId) OVER (partition by userId)
FROM sentSmsTable
JOIN userTable ON userId = sentUserId;
More Related Contents:
- How to perform grouped ranking in MySQL
- If two columns are 1 then make new column
- MySQL – Get row number on select
- Group by clause in mySQL and postgreSQL, why the error in postgreSQL?
- How can I tell when a MySQL table was last updated?
- Retrieving the last record in each group – MySQL
- Cast from VARCHAR to INT – MySQL
- Operand Should Contain 1 Column – MySQL NOT IN
- Connect By Prior Equivalent for MySQL
- Is it possible to query a tree structure table in MySQL in a single query, to any depth?
- MySQL: Error Code: 1118 Row size too large (> 8126). Changing some columns to TEXT or BLOB
- How to convert all tables from MyISAM into InnoDB?
- What’s the difference between comma separated joins and join on syntax in MySQL? [duplicate]
- How to create relationships in MySQL
- Determine Rank based on Multiple Columns in MySQL
- Best practices for SQL varchar column length [closed]
- ALTER TABLE to add a composite primary key
- How to get the count of each distinct value in a column? [duplicate]
- Bash script to insert values in MySQL
- What are differences between INSERT and UPDATE in MySQL?
- How to produce “phantom read” in REPEATABLE READ? (MySQL)
- How do I lag columns in MySQL?
- How to get multiple records against one record based on relation?
- SQL query to check if a name begins and ends with a vowel
- How to use a user variables in MySQL LIKE clause?
- Syntax error on MERGE statement
- How do you force mysql LIKE to be case sensitive? [duplicate]
- #1060 – Duplicate column name ‘id’
- In what order are MySQL JOINs evaluated?
- Update multiple rows with multiple ‘where’ clauses for each individual row