Find the number of unique users in a table

The goal is to find the number of unique users in a table. The table has the following columns: user_id, name. The query should return the number of unique users. In the example above, the answer would be 3.

Problem

Given a table of user data, write a SQL query to find the number of unique users.
Input:
user_id | name
------- | ------
1 | John
2 | Jane
3 | John
4 | Smith
Output:
3

Solution

This solution is in SQL. Our A.I. can create solutions in multiple languages.
by sarastevens
SELECT COUNT(DISTINCT user_id) FROM users;

/*

The above solution is optimal because it uses the COUNT function with the DISTINCT keyword.

*/

A.I. Evaluation of the Solution

The candidate's solution is correct and uses an efficient method to count the number of unique users.

Evaluated at: 2022-11-21 06:16:50