Создание и заполнение базы данных “Игрушки”, страница 4

WHERE  igrushki.stoimost <= thisform.text1.value AND;

thisform.Text2.value >= igrushki.Age_low AND thisform.Text2.value <= igrushki.Age_high;

ORDER BY  igrushki.stoimost

result=temp1/temp2*100

MessageBox("Доля дешевых игрушек: " + alltrim(str(result))+" %")

else

SELECT count(igrushki.nazvanie);

FROM my!igrushki;

WHERE  igrushki.stoimost <= thisform.text1.value;

INTO ARRAY temp1;

SELECT igrushki.nazvanie as Название, igrushki.stoimost as Цена;

FROM my!igrushki;

WHERE  igrushki.stoimost <= thisform.text1.value;

ORDER BY  igrushki.stoimost

result=temp1/temp*100

MessageBox("Доля дешевых игрушек: " + alltrim(str(result))+" %")

endif

close database

Игрушки с заданной датой выпуска:

select igrushki.nazvanie as Название_игрушки,;

       TTOD(igrushki.data_vipuska) as Дата_выпуска from igrushki;

where TTOD(igrushki.data_vipuska)=CTOD(ThisForm.Text1.Value);

group by igrushki.nazvanie;

Игрушки с заданным весом для заданного производителя:

if thisform.optiongroup1.option1.value=1

select igrushki.nazvanie as Игрушки, igrushki.ves as Вес,;

                         postavshik.name_postavshik as Поставщик;

from my!igrushki inner join my!postavshik;

on  igrushki.postavshik==postavshik.id;

where igrushki.ves between ThisForm.Text1.Value and ThisForm.Text2.Value AND;

igrushki.postavshik==(select postavshik.id FROM my!postavshik WHERE postavshik.name_postavshik=thisform.combo1.value);

ORDER BY igrushki.ves

else

select igrushki.nazvanie as Игрушки, igrushki.ves as Вес,;

                         postavshik.name_postavshik as Поставщик; 

from my!igrushki  inner join my!postavshik;

on  igrushki.postavshik==postavshik.id;

where igrushki.ves between ThisForm.Text1.Value and ThisForm.Text2.Value;

ORDER BY igrushki.ves

Endif

Доля игрушек , проданных за определенный промежуток времени:

LOCAL temp1(1)

fmin = thisform.Text1.value

fmax = thisform.Text2.value

use my!igrushki

temp=RECCOUNT()

SELECT count(igrushki.nazvanie);

FROM  my!igrushki; 

WHERE  igrushki.data_prodagi between fmin AND fmax;

INTO ARRAY temp1

result=temp1/temp*100

MessageBox("Доля игрушек за данный период " + alltrim(str(result))+"%")

close databases

Самый популярный вид игрушек для заданного возраста:

LOCAL cntprod(5)

LOCAL temp

close database

use igrushki in 2

use  tip in 1

select 1

do while (!EOF())

             temp=tip.id 

             cntprod=0

             select 2

   select sum(igrushki.koll_prod);

from my!igrushki;

where igrushki.age_low<=THISFORM.Text1.value AND igrushki.age_high>=THISFORM.Text1.value AND;

igrushki.tip==temp;

into array cntprod

Update tip;  

Set avg_cost=cntprod;

Where tip.id=temp

select 1

skip 1

enddo

close databases

 select tip.name_tip, tip.avg_cost;

from my!tip;

where tip.avg_cost=(select max(tip.avg_cost) FROM my!tip)

Самый популярный вид игрушек в целом:

LOCAL cntprod(5)

LOCAL temp

use igrushki in 2

use  tip in 1

select 1

do while (!EOF())

             temp=tip.id 

             cntprod=0

             select 2

   select sum(igrushki.koll_prod);

from my!igrushki;

where igrushki.tip==temp;

into array cntprod

Update tip;  

Set avg_cost=cntprod;

Where tip.id=temp

select 1

skip 1

enddo

 select tip.name_tip, tip.avg_cost;

from my!tip;

where tip.avg_cost=(select max(tip.avg_cost) FROM my!tip)

close databases

Игрушки, поступившие от заданного поставщика, чья стоимость больше стоимости другой выбранной  игрушки:

LOCAL temp(1)

LOCAL temp1(2)

select Distinct(igrushki.postavshik);

from my!igrushki;

where igrushki.postavshik == (select postavshik.id FROM my!postavshik WHERE postavshik.name_postavshik=thisform.combo3.value);

Into array temp

select igrushki.stoimost FROM my!igrushki;

WHERE igrushki.postavshik==temp AND igrushki.nazvanie = thisform.combo2.value;

INTO ARRAY temp1

num = alen(temp1)

if num==2 

num=0

else

num=temp1