6 Replies Latest reply on Nov 14, 2016 10:29 AM by John Croft

    "OR" function in a join

    Natali Talevski

      Hi,

       

      We're trying to create a join between 2 tables that incorporates an "OR" function in the criteria, as outlined below. The join clauses look like they only allow one type of clause and not either/or.

       

      Has anyone done this before?

       

      Thanks

       

      Natali

       

      Table 1 (User)

      UserId

      UserName

       

      Table 2 (Calls)

      CallId

      Time

      Caller

      Callee

       

      Query:

      select

             u.UserName,

             count(*) as Total,

             max(c.Time) as 'Time'

      from

      Calls c

      inner join

      Users u

      on

      1. c.Caller = u.UserId OR c.Callee = u.UserId

      group by

      1. u.UserName

      order by

      Total desc

       

       

      Expected:

      • A list of users who have made the calls, and the count of calls that have been made.