castleWolf
Instructor
Hi everyone,
Can anyone help me to improve the query
first i wanna to explain that what customer wanted for the first time,and after it he changed his mind and wanted another report which is diffcult to do for me.
First he wanted that to display 1 year payment by month
exactly:
Select customerid,
Min(Iif(Month(date_of_payment)=1,"+","-")) m1,;
MIN(Iif(Month(date_of_payment)=2,"+","-")) m2,;
MIN(Iif(Month(date_of_payment)=3,"+","-")) m3,;
MIN(Iif(Month(date_of_payment)=4,"+","-")) m4,;
MIN(Iif(Month(date_of_payment)=5,"+","-")) m5,;
MIN(Iif(Month(date_of_payment)=6,"+","-")) m6,;
MIN(Iif(Month(date_of_payment)=7,"+","-")) m7,;
MIN(Iif(Month(date_of_payment)=8,"+","-")) m8,;
MIN(Iif(Month(date_of_payment)=9,"+","-")) m9,;
MIN(Iif(Month(date_of_payment)=10,"+","-")) m10,;
MIN(Iif(Month(date_of_payment)=11,"+","-")) m11,;
MIN(Iif(Month(date_of_payment)=12,"+","-")) m12;
from Payment ;
WHERE date_of_payment>=first_date;
AND date_of_payment<=last_date;
AND Not Deleted();
group By customerid Into Cursor who_payed_in_year
but all this cases range between date is 12 month.
now he wants that range must be any range but between range is always 12 month.
exacly :
in first task i wrote
first_date='01.01.2004'
last_date='31.12.2004'
but now he wants that the range must be like that
first_date='01.06.2004'
last_date='31.05.2005'
or
first_date='01.02.2004'
last_date=' 31.01.2005'(in all cases between date is 12 month)
and i see that
Min(Iif(Month(date_of_payment)=1,"+","-")) this construction doesn't solve my problem.
How can i do it?
somebody give me an idea.
Can anyone help me to improve the query
first i wanna to explain that what customer wanted for the first time,and after it he changed his mind and wanted another report which is diffcult to do for me.
First he wanted that to display 1 year payment by month
exactly:
Select customerid,
Min(Iif(Month(date_of_payment)=1,"+","-")) m1,;
MIN(Iif(Month(date_of_payment)=2,"+","-")) m2,;
MIN(Iif(Month(date_of_payment)=3,"+","-")) m3,;
MIN(Iif(Month(date_of_payment)=4,"+","-")) m4,;
MIN(Iif(Month(date_of_payment)=5,"+","-")) m5,;
MIN(Iif(Month(date_of_payment)=6,"+","-")) m6,;
MIN(Iif(Month(date_of_payment)=7,"+","-")) m7,;
MIN(Iif(Month(date_of_payment)=8,"+","-")) m8,;
MIN(Iif(Month(date_of_payment)=9,"+","-")) m9,;
MIN(Iif(Month(date_of_payment)=10,"+","-")) m10,;
MIN(Iif(Month(date_of_payment)=11,"+","-")) m11,;
MIN(Iif(Month(date_of_payment)=12,"+","-")) m12;
from Payment ;
WHERE date_of_payment>=first_date;
AND date_of_payment<=last_date;
AND Not Deleted();
group By customerid Into Cursor who_payed_in_year
but all this cases range between date is 12 month.
now he wants that range must be any range but between range is always 12 month.
exacly :
in first task i wrote
first_date='01.01.2004'
last_date='31.12.2004'
but now he wants that the range must be like that
first_date='01.06.2004'
last_date='31.05.2005'
or
first_date='01.02.2004'
last_date=' 31.01.2005'(in all cases between date is 12 month)
and i see that
Min(Iif(Month(date_of_payment)=1,"+","-")) this construction doesn't solve my problem.
How can i do it?
somebody give me an idea.