chargeTheWorld
chargeTheWorld

Reputation: 1

My SQL query (in Zoho Analytics) isn't working and I'm not sure why

Solved: I was using a reserved term 'USER' unknowingly.

For context, I'm very new to SQL. My goal in the script below is to combine multiple data tables into a single query table in Zoho Analytics. From this query table I will generate reports. The data in the source tables are already populated.

When I go to execute the query, I get a non-informative error from Zoho Analytics saying it doesn't support this query and no output.

Do you see anything wrong with my code?

SELECT
         SITE."name" as 'Site Name',
         SESSION."Id" as 'Session ID',
         SESSION."userId" as 'User ID',
         SESSION."status" as 'Status',
         SESSION."chargePointId" as 'ChargePoint ID',
         SESSION."amount" as "Value",
         SESSION."Calc - Energy [kWh]" as 'Energy',
         SESSION."Calc - Start Datetime" as 'Start',
         SESSION."Calc - End Datetime" as 'End',
         SESSION."Calc - Session Duration" as 'Session Duration',
         SESSION."Calc - Est. Charge Duration" as 'Charge Duration',
         SESSION."reason" as 'Termination Reason',
         CHARGER."tags_0" as 'Tags'
FROM "Sessions Table" AS  SESSION
JOIN "Chargers Table" AS  CHARGER ON SESSION."chargePointId" = CHARGER."id"
JOIN "Sites Table" AS  SITE ON CHARGER."locationId"  = SITE."id"
JOIN "Partners Table" AS PARTNER ON CHARGER."ownerPartnerID" = PARTNER."id"
JOIN "Users Table" AS USER ON SESSION."userID" = USER."id"
ORDER BY 'Session ID' DESC 

Here is the output I get from Zoho when I try to run it.

Error Details: Your SQL Query is not supported in Zoho Analytics. If you wish to report this as a bug, send a screenshot of your query to [email protected].

Upvotes: 0

Views: 153

Answers (1)

Mauro Vanetti
Mauro Vanetti

Reputation: 512

USER is a reserved keyword. Put it in quotes.

Upvotes: 0

Related Questions