Govur University Logo
--> --> --> -->
...

How do you write a SQL query to count the number of unique customers who made a purchase on a specific date from a sales transaction table that logs every item purchased?



To write a SQL query that counts the number of unique customers who made a purchase on a specific date from a sales transaction table, you will use the `SELECT`, `COUNT`, `DISTINCT`, `FROM`, and `WHERE` clauses. Assume your sales transaction table is named `sales_transactions` and it contains columns like `customer_id` to identify each unique customer and `transaction_date` to log the date of each purchase. The SQL query to achieve this for a specific date, for example, '2023-10-26', is: SELECT COUNT(DISTINCT customer_id) AS UniqueCustomersPurchased FROM sales_transactions WHERE transaction_date = '2023-10-26'; Let's break down each part of this query: `SELECT COUNT(DISTINCT customer_id)`: `SELECT` is the SQL keyword used to specify which data you want to retrieve from the database. `COUNT()` ....

Log in to view the answer



Redundant Elements