Создание и заполнение базы данных "Агент", страница 4

DO CASE

                  CASE Thisform.cost1_for_agent.value = 0

                  DO CASE

                              CASE Thisform.find_goods.Value = 1

                              set step on

                                         select goods_name, model, producer, suppler, cost from agent;

                                         inner join goods on goods.goods_id=agent.goods_id;

                                         inner join producers on producers.produce_id=goods.produce_id;

                                         inner join supplers on supplers.suppler_id=goods.suppler_id;

                                         where cost=(select max(cost) from agent)

                              CASE Thisform.find_goods.Value  = 2

                                         select goods_name, model, producer, suppler, cost from agent;

                                         inner join goods on goods.goods_id=agent.goods_id;

                                         inner join producers on producers.produce_id=goods.produce_id;

                                         inner join supplers on supplers.suppler_id=goods.suppler_id;

                                         where cost=(select min(cost) from agent)

                              CASE Thisform.find_goods.Value  = 3

                                         select avg(cost) as  "Ñðåäíÿÿ_ñòîèìîñòü" from agent

                  ENDCASE

                  CASE Thisform.cost1_for_agent.value = 1

                  DO CASE

                              CASE Thisform.find_goods.Value = 1

                                         select surname, goods_name, model, producer, suppler, cost from agent;

                                         inner join goods on goods.goods_id=agent.goods_id;

                                         inner join producers on producers.produce_id=goods.produce_id;

                                         inner join supplers on supplers.suppler_id=goods.suppler_id;

                                         where cost=(select max(cost) from agent where surname=thisform.c1_agent.value)

                              CASE Thisform.find_goods.Value  = 2

                                         select surname, goods_name, model, producer, suppler, cost from agent;

                                         inner join goods on goods.goods_id=agent.goods_id;

                                         inner join producers on producers.produce_id=goods.produce_id;

                                         inner join supplers on supplers.suppler_id=goods.suppler_id;

                                         where cost=(select min(cost) from agent where surname=thisform.c1_agent.value)

                              CASE Thisform.find_goods.Value  = 3

                                         select avg(cost) as  "Ñðåäíÿÿ_ñòîèìîñòü" from agent         where surname=thisform.c1_agent.value

                  ENDCASE

ENDCASE

6.  Все товары с заданным интервалом цены по  заданному агенту и в целом.

DO CASE

                        CASE Thisform.cost2_for_agent.value = 0

                        select surname, goods_name, model, suppler, producer, weight, outputdate;

                        sale_date, cost;

                        from agent;

                        inner join goods on agent.goods_id=goods.goods_id;

                        inner join producers on producers.produce_id=goods.produce_id;

                        inner join supplers on supplers.suppler_id=goods.suppler_id;

                                               where cost>=thisform.cost1.value AND;

                                                              cost<=thisform.cost2.value

                        CASE Thisform.cost2_for_agent.value = 1