不好意思,小弟愚钝,没有数据库的基础,加上刚接触InterBase,还得有劳各位仁兄帮忙。仅仅
是毕设项目,时间不多了,还得应付交差,实在没办法。
CREATE PROCEDURE GET_B (
MINCOST INTEGER,
MAXCOST INTEGER
) RETURNS (
AA CHAR(255),
AA1 CHAR(255),
BB CHAR(10),
CC INTEGER,
DD INTEGER
) AS
BEGIN
FOR SELECT zone.zonename,phone.phoneid,SUM(cost.cost)
FROM cost,zone,phone
WHERE zone.ZONEID=phone.ZONEID
AND phone.PHONEID=cost.PHONEID
group by zonename,phoneid having sum(cost)<=:mincost
order by zoneid
INTO:aa,:bb,:cc
DO
FOR SELECT zonename,SUM(cost.cost)
FROM cost,zone,phone
WHERE zone.ZONEID=phone.ZONEID
AND phone.PHONEID=cost.PHONEID
group by zonename,phoneid having sum(cost)>=:maxcost
order by zoneid
INTO:aa1,dd
DO
SUSPEND;
END
如果这样的话,仅仅只能各自统计,没法将之进行联接,有的进行统计,没有的时候记0。
zone >500 <300
a1 0 5
a2 5 0
a3 1 6
还恳请仁兄帮忙指正。