Get total sales of invoice customer using sql query in dynamics ax

Description:-

In this query we will see about how to get invoice customer total sales based on parameter. Here I have I have used my custom table for map customer accounts and get totals invoice customer sales for that customer which is in my customer table. Based on invoice date I have pass parameter for getting particular range data.

SQL Query:-

select sum(SALESLINE.LINEAMOUNT),SALESTABLE.CUSTGROUP from SALESTABLE
join CUSTINVOICEJOUR on CUSTINVOICEJOUR.SALESID = SALESTABLE.SALESID and SALESTABLE.SALESSTATUS = 3 
join SALESLINE on SALESLINE.SALESID = SALESTABLE.SALESID
join CUSTOMTABLE on CUSTOMTABLE.CustAccount = SALESTABLE.CUSTACCOUNT
where CUSTINVOICEJOUR.INVOICEDATE >= '<FromDate>' and CUSTINVOICEJOUR.INVOICEDATE <= '<ToDate>'
and SALESLINE.DATAAREAID ='<Company>' and CUSTINVOICEJOUR.DATAAREAID = '<Company>' and SALESTABLE.DATAAREAID = '<Company>' and CUSTOMTABLE.DATAAREAID = '<Company>'
group by SALESTABLE.CUSTGROUP 
order by SALESTABLE.CUSTGROUP asc

Related Posts

Thanks for comments.....

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
:-?
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
$-)
(y)
(f)
x-)
(k)
(h)
cheer