• Are you missing the Join condition?

    In your query, all columns in the SELECT clause belong to BillingRecord table.

    You are using the package type table but it is not JOINed with BillingRecord Table. So, it displays twice.

    select c.accountid,c.offername,min(c.startdate),max(c.enddate)

    from billingRecord c, packagetype p

    where

    -- This could be the missing part

    -- c....= p... and

    packagetypeid in (0,2) and c.accountid in ('123456789', '321654987')

    group by c.accountid,c.offername

    order by 1

    Cheers,
    Prithiviraj Kulasingham

    Plan to Test your Plan!