I have a few queries of this type that I think I would like to update to take advantage of CTE, but I really could use some help in getting started. Here is the code:
I seem to remember that CTEs can be much better for aggregates than the compute sum and then rs.NextRecordset that I have always done with SQL 2000 and ASP. And following those lines, is it fairly straightforward how to access the resulting values from ASP when using CTEs?
Thanks for any help you can give me.
wb
Code:
select rd.event_id,rd.insert_date, rd.num_spaces, cost_per_space, deposit_per_space, Total_Cost, amt_paid, (total_cost-amt_paid) AS balance_due, r.registration_id, e.ministry_id, r.contact_id
from ycmhome.contactinfo ci join ycmhome.registration r on ci.contact_id = r.contact_id
join ycmhome.reg_details rd on r.registration_id = rd.registration_id
join ycmhome.events e on rd.event_id = e.event_id
where ci.church_id = " & cid
and rd.event_id = " & eid
and r.isactive = 1
order by rd.event_id
compute sum(rd.num_spaces), sum(total_cost), sum(amt_paid), sum(total_cost-amt_paid) by rd.event_id
I seem to remember that CTEs can be much better for aggregates than the compute sum and then rs.NextRecordset that I have always done with SQL 2000 and ASP. And following those lines, is it fairly straightforward how to access the resulting values from ASP when using CTEs?
Thanks for any help you can give me.
wb