title: Pyspark sql query not working, problematic group by
body: <p>Im trying to get working  this code but when i transfer it from SAS to pyspark sql its not working. if i add a group by im some part it works but it gives me an empty table</p>
  
  <p>The group by 1 after "Online" its what removes me the error but gives empty table.</p>
  
  <pre class="lang-py prettyprint-override"><code>Online = spark.sql(
  '''SELECT DISTINCT tAuxiliar.canalidad,
                  CASE
                      WHEN tAuxiliar.percentil &lt; 0.25 THEN "p25"
                      WHEN tAuxiliar.percentil &gt;= 0.25
                           AND tAuxiliar.percentil &lt; 0.50 THEN "p50"
                      WHEN tAuxiliar.percentil &gt;= 0.50
                           AND tAuxiliar.percentil &lt; 0.75 THEN "p75"
                  END AS grupo,
                  max(corte_max) AS percentil
  FROM
    (SELECT "Online" AS canalidad,
            tPercen.percentil,
            min(tPercen.operaciones) AS corte_min,
            max(tPercen.operaciones) AS corte_max
     FROM
       (SELECT operaciones,
               percentile_approx(operaciones, 1) AS percentil
        FROM base_canalidad_unica
        WHERE canalidad = "Online"
        GROUP BY 1) AS tPercen
     GROUP BY 1,
              2) AS tAuxiliar
  WHERE tAuxiliar.percentil &lt; 0.75
  GROUP BY 1,
           2''')
  </code></pre>