I have a table that I want to summarize by utilityno. However, If the detail has more than 36, I want two rows. One with 36 and the next with the balance. So If I have 42 records, I want 36 on one row and a count of 6 on the next.
Here is my SQL thus far
SELECT count(trdate) as Items
,[UtilityNo]
,[UtilityName1]
,Max([TrDate]) as Date
,Max([Branch]) as Branch
,Sum(CustAmount) as Amount
FROM [TellerApp2000SQL].[dbo].[UtilityDetail]
where trdate7 = 2015215 and branch = 4
-- Having mod(Items , 36)
group by utilityno,utilityname1
order by utilityno
Which gets me this
Items Name Amount
2 Northn 75.50
43 Magnolia r Assn 5,373.28
1 Friendship C, Inc 18.50
32 SunnyHill Water Assn 946.20
1 Fernwoodewerage Assn 79.74
So the Magnolia r Assn needs a row with 36 Items and another with 7.
If the same company had 105 items, I need 3 rows (36,36 and 33)
Sorry about the table above, I couldn't get it in a tabular form.
Thanks in advance.
Jim