I am trying to get data for entered person, I want to pull out data as No of invoices and No of line items for particular person.
The output is
Entered_by No of line items
CD 9
CD 136084
deepa 7
deepa 18
dolly 757
dolly 22350
kroshni 666
kroshni 16161
lokesh 4
lokesh 999
MHeera 639
MHeera 20427
nandini 7
nandini 5318
Here the data in No of line items is mixing of both ’ No of line items’ count and ‘No of invoices’ count, I want to show like
Entered_by No of line items No of invoices
CD 136084 9
deepa 18 7
dolly 22350 757
Please help me with this somebody …..
Here is the T-SQL query
select ENTERED_BY, count(entered_by) 'NO OF LINE ITEMS'
from im_invoice, im_invoice_line_item, im_invoice_inventory
where invoice_rid = invoice_fk
and invoice_inventory_rid = invoice_inv_fk
and enter_date between dateadd(mm, -3, getdate()) and dateadd(mm,0,getdate())
group by entered_by
union
select entered_by, count(invoice_num) 'NO OF INVOICES' from im_invoice
where enter_date between dateadd(mm, -3, getdate()) and dateadd(mm,0,getdate())
group by entered_by
invoice_rid,invoice_fk,invoice_inventory_ridandinvoice_inv_fkbelong to?