Question: SQL ERROR near returning WITH total _ customers AS ( SELECT COUNT ( DISTINCT customerID ) AS total FROM JVS _ Schema.Customer ) ,

SQL ERROR near returning
WITH total_customers AS (
SELECT COUNT(DISTINCT customerID) AS total
FROM "JVS_Schema".Customer
),
returning_customers AS (
SELECT COUNT(DISTINCT C.customerID) AS Returning
FROM "JVS_Schema".Customer AS C
JOIN "JVS_Schema".Rental AS R ON R.CustomerID=C.CustomerID
JOIN "JVS_Schema".Order AS O ON R.OrderID=O.OrderID
GROUP BY C.customerID HAVING COUNT(O.OrderID)>1
)
SELECT (returning_customers.returning / C.total)*100 AS retention_rate
FROM returning_customers AS returning, total_customers AS total;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!