SELECT distinct UtilityType,
MeterNumberID,
AccountNumberID,
AccountNumber,
billedAmount,
ServiceFromDate,
serviceToDate,
DATEPART(YEAR,ServiceFromDate) AS ServiceFromYear,
DATEPART(MONTH,ServiceFromDate) AS ServiceFromMonth,
DATEPART(YEAR,ServiceToDate) AS ServiceToYear,
DATEPART(MONTH,ServiceToDate) AS ServiceToMonth,
DATEDIFF(DAY,ServiceFromDate,ServiceToDate) AS myDaysInCycle,
CASE
WHEN ServiceFromDate = serviceToDate THEN 1
ELSE BilledAmount/DATEDIFF(DAY, ServiceFromDate, servicetodate)
END AS myDailyRate