Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
master_student
Creator III
Creator III

follow per day/month in the same query

Hello guys

Hope you're doing very good.

I have a query that contains those fields :

select   to_date('2016-09-26' ,'YYYY-MM-DD') as extract date, inv.billing_period,

sum(case when pt.segment_type is not null then payment.Total_payment else 0 end) as paid_amount,

sum(total_invoice_amount) as CA

from

.....

where to_date('2016-09-26' ,'YYYY-MM-DD') between cas.valid_from and cas.valid_to

and billing_period >='200305'

the billing period is the strat of month 0101 /0102/0103, it is used to follow the CA

The paid amount changes according to the extract date (in a daily way)


The result is something like this :

Extract datebilling_periodpaid_amountCA
2016-09-260109201625226356



what I need as a result now is to measure the changes of paid amount in a daily way by using the extract date field

Capture.JPG

what I am doing right now is to concatenate the same query many time to get the sum paid amount acccording to many extract dates :

select   to_date('2016-09-27 ,'YYYY-MM-DD') as extract date, inv.billing_period,

sum(case when pt.segment_type is not null then payment.Total_payment else 0 end) as paid_amount,

sum(total_invoice_amount) as CA

from

.....

where to_date('2016-09-26' ,'YYYY-MM-DD') between cas.valid_from and cas.valid_to

and billing_period >='200305'

concatenate

select   to_date('2016-09-26' ,'YYYY-MM-DD') as extract date, inv.billing_period,

sum(case when pt.segment_type is not null then payment.Total_payment else 0 end) as paid_amount,

sum(total_invoice_amount) as CA

from

.....

where to_date('2016-09-26' ,'YYYY-MM-DD') between cas.valid_from and cas.valid_to

and billing_period >='200305'




any other solutions please..

Thanks

3 Replies
master_student
Creator III
Creator III
Author

Any help please???

el_aprendiz111
Specialist
Specialist

Hi,

Would you be able to share a sample with the expected output?

in excel

master_student
Creator III
Creator III
Author

Hi fer fer

Just to clarify my request, bellow are more details :

I have a query that gives measures for the whole period since 201302 until now in a monthly way. the measures of this query changes according to the date of extract.

form example

date extract

29/09/20016  the CA for the whole period (since 201302 until now 201610) is 120

30/09/20016  the CA for the whole period (since 201302 until now 201610) is 125

For now I am changing the extract date manually like this and join queries :

select

to_date('2016-10-02' ,'YYYY-MM-DD'),  // extractdate

inv.billing_period, case when nb_contract_actif > 0 THEn 'a' else 's' end as status  ,

ct.customer_type_description,

sum(total_invoice_amount) as CA

from

                                               where to_date('2016-10-02' ,'YYYY-MM-DD') between cas.valid_from and cas.valid_to

                                               )...

  left  join (

                                 select

                                               where to_date(ip.Payment_Received_Date,'yyyy-mm-dd') <=to_date('2016-10-02' ,'YYYY-MM-DD')

                                             

       left outer join (

                               

                                               where to_date(ip.Payment_Received_Date,'yyyy-mm-dd') <=to_date('2016-10-02' ,'YYYY-MM-DD')

join

select

to_date('2016-10-01' ,'YYYY-MM-DD'),  // extractdate

inv.billing_period, case when nb_contract_actif > 0 THEn 'a' else 's' end as status  ,

ct.customer_type_description,

sum(total_invoice_amount) as CA

from

                                               where to_date('2016-10-01' ,'YYYY-MM-DD') between cas.valid_from and cas.valid_to

                                               )...

  left  join (

                                 select

                                               where to_date(ip.Payment_Received_Date,'yyyy-mm-dd') <=to_date('2016-10-01' ,'YYYY-MM-DD')

                                             

       left outer join (

                               

                                               where to_date(ip.Payment_Received_Date,'yyyy-mm-dd') <=to_date('2016-10-01' ,'YYYY-MM-DD')

and so on...

How can I change the extract date in red automatically please for a given period form example from 20160901 until today...

Thanks in advance