3 Replies Latest reply on Jun 29, 2016 8:15 AM by Derrick Austin

    Using Parameters in a Custom-Query

    Matan Bracha

      Hi, I'm writing a custom query - and I'm using parameters to build it.

      I need to use the parameters to filter out data - meaning use them in the "Where" clause.


      For instance, I have a parameter called "Country" and it has the options: All, Albania, Belgium, Canada etc.

      So my query looks something like this:


      SELECT EventDate, Hour_Num, CountryCode, SUM(Install) Installs

      FROM `Installs`

      WHERE Hour_Num<25 AND (EventDate=<Parameters.Date1> OR EventDate=<Parameters.Date2>)

          AND (CASE WHEN <Parameters.Country>='ALL' THEN (Hour_num<25) ELSE (CountryCode=<Parameters.Country>) END)

      GROUP BY 1,2,3


      So these are my questions:

      1. Is there a nicer way to write this query without multiplying conditions (for the "All" choice)? - My DB is MySQL.

      2. The query takes too long to show the initial view - is there a way not to shoe anything until the user chooses the correct parameters and wants to see the view?

      My main problem here is the running times...


      Thank you very much!!