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

    from billingRecord c, packagetype p

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

    and c.startdate is NOT NULL and c.enddate is NOT NULL

    group by c.accountid,c.offername

    order by 1

    go