Zoho reports query table problem
Hi,
I wanted to ask you a question regarding one query that I am trying to build so I can make a report out of it.
I had 2 requirements:
1. Get the potentials that have reached the red zone, and the red zone is a percentage of probability for that potential.
2. Get the potentials that have reached the red zone and ended up being won. The red zone will also be chosen in the report slider.
For the first one I solved the problem by using this query :
- SELECT
- potential."POTENTIALID" AS "Potential Id",
- potential."Potential Owner" AS "Potential Owner",
- potential."Potential Name" AS "Potential Name",
- potentialHistory."Modified Time" AS "modified",
- groupedtt."MaxProbability"
- FROM "Potentials" potential INNER JOIN "Potentials Stage History" potentialHistory ON potential."POTENTIALID" = potentialHistory."POTENTIALID" INNER JOIN( SELECT
- "Potentials Stage History"."POTENTIALID" AS "PotentialID",
- MAX("Potentials Stage History"."Probability (%)") AS "MaxProbability"
- FROM "Potentials Stage History"
- GROUP BY "Potentials Stage History"."POTENTIALID"
- ) groupedtt ON potentialHistory."Probability (%)" = groupedtt."MaxProbability".
- AND potentialHistory."POTENTIALID" = groupedtt."PotentialID"
And reporting on max probability on the reports.
Now for the second one I a trying to add to that query these following lines:
- WHERE EXISTS
- (
- SELECT p2."POTENTIALID" FROM "Potentials Stage History" p2 WHERE potentialHistory."POTENTIALID" = p2."POTENTIALID" AND p2."Stage"='Closed Won'
- )
But I am getting this error : "
Unknown table or alias 'potentialHistory' used in select query."
Any help would be greatly appreciated.
Best regards,
Edison Rama