Quantcast
Channel: MySQL Conditional Counter Based Other Columns? - Database Administrators Stack Exchange
Browsing all 2 articles
Browse latest View live

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



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
Browsing all 2 articles
Browse latest View live




Latest Images