SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
SELECT c.CustomerName, j.VisitType, j.VisitDate, j.Duration, j.SpendAmount FROM (SELECT CustomerID, VisitDate, Duration, NULL AS SpendAmount, 'Online' AS VisitType FROM OnlineVisits UNION SELECT CustomerID, VisitDate, NULL AS Duration, SpendAmount, 'Store' AS VisitType FROM StoreVisits) AS j JOIN Customers c ON j.CustomerID = c.CustomerID WHERE c.Age > 25 AND (j.Duration > 30 OR j.SpendAmount > 1000) ORDER BY j.VisitDate;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear