Quantcast
Channel: MySQL Conditional Counter Based Other Columns? - Database Administrators Stack Exchange
Browsing index pages (2 articles)
↧

MySQL Conditional Counter Based Other Columns?

I have a query that returns purchases for all customers in a store across a date range. It works fine, but now I've been asked to modify the results so only the first purchase per customer per day is...

View Article


Answer by Akina for MySQL Conditional Counter Based Other Columns?

SELECT t.*, CASE WHEN CONCAT(t.CustomerName, CHAR(0), t.PurchaseDate) = @group THEN @num:=@num+1 ELSE @num:=1 END PurchaseNumberForDate,@group:=CONCAT(t.CustomerName, CHAR(0), t.PurchaseDate)...

View Article

Browsing index pages (2 articles)


Latest Images