-- --MONTHLY SALES REPORT -- SELECT p21_sales_history_report_view.customer_name, p21_sales_history_report_view.customer_id, p21_sales_history_report_view.item_id, p21_sales_history_report_view.salesrep_id, p21_sales_history_report_view.taker, p21_sales_history_report_view.sales_location_id, p21_sales_history_report_view.period, p21_sales_history_report_view.year_for_period, p21_sales_history_report_view.sales_price_home, p21_sales_history_report_view.cogs_amount_home, p21_sales_history_report_view.invoice_no, p21_view_contacts.first_name, p21_view_contacts.last_name, p21_sales_history_report_view.sales_location_name, p21_sales_history_report_view.other_charge_item, p21_sales_history_report_view.company_id, p21_sales_history_report_view.invoice_line_uid_parent FROM p21_sales_history_report_view p21_sales_history_report_view INNER JOIN p21_view_contacts p21_view_contacts ON p21_sales_history_report_view.salesrep_id=p21_view_contacts.id WHERE p21_sales_history_report_view.company_id = '10' AND p21_sales_history_report_view.year_for_period >= 2023 AND p21_sales_history_report_view.year_for_period <= 2024 AND p21_sales_history_report_view.salesrep_id >= '0' AND p21_sales_history_report_view.salesrep_id <= '999999999' AND p21_sales_history_report_view.sales_location_id >= 0 AND p21_sales_history_report_view.sales_location_id <= 999999999 AND p21_sales_history_report_view.invoice_line_uid_parent = 0 -- --ROLLING SALES FOR 2 YEARS -- SELECT p21_sales_history_report_view.customer_name, p21_sales_history_report_view.customer_id, p21_sales_history_report_view.item_id, p21_sales_history_report_view.salesrep_id, p21_sales_history_report_view.taker, p21_sales_history_report_view.sales_location_id, p21_sales_history_report_view.period, p21_sales_history_report_view.year_for_period, p21_sales_history_report_view.sales_price_home, p21_sales_history_report_view.cogs_amount_home, p21_sales_history_report_view.invoice_no, p21_view_contacts.first_name, p21_view_contacts.last_name, p21_sales_history_report_view.company_id, p21_sales_history_report_view.other_charge_item, p21_sales_history_report_view.invoice_line_uid_parent FROM p21_sales_history_report_view p21_sales_history_report_view INNER JOIN p21_view_contacts p21_view_contacts ON p21_sales_history_report_view.salesrep_id = p21_view_contacts.id WHERE p21_sales_history_report_view.company_id = '10' AND p21_sales_history_report_view.year_for_period >= 2022 AND p21_sales_history_report_view.year_for_period <= 2024 AND p21_sales_history_report_view.salesrep_id >= '0' AND p21_sales_history_report_view.salesrep_id <= '999999999' AND p21_sales_history_report_view.sales_location_id >= 0 AND p21_sales_history_report_view.sales_location_id <= 999999999 AND p21_sales_history_report_view.invoice_line_uid_parent = 0 ORDER BY p21_sales_history_report_view.salesrep_id -- --TOP 25 -- SELECT p21_sales_history_report_view.customer_name, p21_sales_history_report_view.customer_id, p21_sales_history_report_view.item_id, p21_sales_history_report_view.salesrep_id, p21_sales_history_report_view.taker, p21_sales_history_report_view.sales_location_id, p21_sales_history_report_view.period, p21_sales_history_report_view.year_for_period, p21_sales_history_report_view.sales_price_home, p21_sales_history_report_view.cogs_amount_home, p21_sales_history_report_view.invoice_no, p21_view_contacts.first_name, p21_view_contacts.last_name, p21_sales_history_report_view.company_id, p21_sales_history_report_view.other_charge_item, p21_sales_history_report_view.invoice_line_uid_parent FROM p21_sales_history_report_view p21_sales_history_report_view INNER JOIN p21_view_contacts p21_view_contacts ON p21_sales_history_report_view.salesrep_id=p21_view_contacts.id WHERE p21_sales_history_report_view.company_id = '10' AND p21_sales_history_report_view.year_for_period >= 2022 AND p21_sales_history_report_view.year_for_period <= 2024 AND p21_sales_history_report_view.salesrep_id >= '0' AND p21_sales_history_report_view.salesrep_id <= '999999999' AND p21_sales_history_report_view.sales_location_id >= 0 AND p21_sales_history_report_view.sales_location_id <= 999999999 AND p21_sales_history_report_view.invoice_line_uid_parent = 0