3 Replies Latest reply on Aug 11, 2018 11:14 AM by andre riley

    Convert SQL to Tableau syntax

    andre riley

      Hi Community,

       

      I need some help with converting an SQL query to tableau calculations but it's currently beyond my skill set. Attached is the source data with the view I'm looking to achieve as a result of the calculation. Can you help me please?

       

      SELECT "Month"

          , ID

          , Name

          , MAX(ending_team) OVER (PARTITION BY ID, Name ORDER BY "Month" ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) AS Starting_Team

          , Ending_Team

      FROM

          (

                   SELECT "Month"

                 , ID

                 , Name

                 , Team AS Ending_Team

                 , COUNT(DISTINCT call_id) AS mostCalls

                   FROM sourcedata

                   GROUP BY 1,2,3,4

                   QUALIFY ROW_NUMBER() OVER (PARTITION BY "Month", ID, Name ORDER BY mostCalls DESC) = 1