SELECT Orders_Customers."FirstName" ||' ' || Orders_Customers."LastName" 'Customer Name', Orders_Customers."Email", COUNT(*) AS "Orders count", SUM(Orders."TotalIncTax") AS "Amount Spent" FROM "Orders" LEFT OUTER JOIN "Customers" AS Orders_Customers ON "Orders"."CustomerId" = Orders_Customers."id" WHERE (Orders."StatusId" != 4 AND Orders."StatusId" != 5) and strftime('%Y', Orders."DateCreated")='2016' GROUP BY 'Customer Name', Orders_Customers."Email" ORDER BY SUM(Orders."TotalIncTax") desc LIMIT 20
Skyvia Query allows you to run SQL queries against databases and cloud applications from web browser. Access and manage your data from anywhere, build reports, arrange your data in the most informative way and simplify your decision-making process easily!