1 Reply Latest reply on Jan 20, 2017 8:03 AM by shawkins

    How to create view based on sql script with "aggregate functions" and "group by"

    rahulkumarsharma

      Hi,

      This is sql query. Based on this, i am going to create View.

      My view should return same result as this sql query.

      i have to use "aggregate functions"and "group by" with joins in query.

       

      Select cc.country_name Country,  sh.department Department, E.id EmployeeID, E.last_name Surname, E.first_name ForeName ,
      MAX(apop.scheduledEndDateTime)
      from employees_and_assets.employee E
      inner join employees_and_assets.country Ec on Ec.external_id = E.external_id
      inner join country.country cc on cc.country_iso = Ec.code
      inner join g4s_scheduler.schedule_history sh on sh.employee_id = E.id
      inner join attendance.PROOF_OF_PRESENCE apop on apop.siteID = sh.site_id
      group by cc.country_name ,  sh.department, E.id , E.last_name , E.first_name