Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
3.5 kB
4
Indexable
Never
SELECT 
    main_designin.*,
    dcs.request_date,
    dcs.project_name,
    dcs.project_engineer,
    dcs.customer_name,
    dcs.bel_part_number,
    dcs.customer_part_number,
    dcs.quote_identifier,
    dcs.estimated_annual_usage,
    dcs.production_timeframe,
    dcs.engineering_design_qualification,
    dcs.purchase_location,
    dcs.shipping_location,
    dcs.commission_rep_number,
    dcs.approved_by,
    dcs.approval_date,
    dcs.contract_manufacturer,
    dcs.quote_effective_date,
    dcs.record_creator_identifier,
    dcs.comments,
    dcs.distributor_who_is_purchasing,
    dcs.record_status,
    dcs.internal_part_number,
    dcs.origin_information,
    dcs.sales_code,
    dcs.manufacturing_location,
    dcs.split_design,
    dcs.territory,
    dcs.year,
    dcs.quarter,
    CONCAT((SELECT 
                    GROUP_CONCAT(dcu.commission_percentage
                            ORDER BY dcu.id DESC
                            SEPARATOR '%, ')
                FROM
                    belfserv_B.design_commissions_unique dcu
                WHERE
                    dcu.design_commissions_shared_identifier = main_designin.design_commissions_shared_identifier),
            '%') AS commission_rep_percentages,
    (SELECT 
            GROUP_CONCAT(DISTINCT dcu.rep_name
                    ORDER BY dcu.id DESC
                    SEPARATOR ', ')
        FROM
            belfserv_B.design_commissions_unique dcu
        WHERE
            dcu.design_commissions_shared_identifier = main_designin.design_commissions_shared_identifier
        ORDER BY main_designin.id DESC) AS rep_names
FROM
    belfserv_B.design_commissions_unique AS main_designin
        INNER JOIN
    belfserv_B.design_commissions_shared dcs ON dcs.id = main_designin.design_commissions_shared_identifier
        AND ((dcs.`bel_part_number` LIKE '%pending%')
        OR (dcs.`contract_manufacturer` LIKE '%pending%')
        OR (dcs.`customer_name` LIKE '%pending%')
        OR (dcs.`project_name` LIKE '%pending%')
        OR (dcs.`quote_identifier` LIKE '%pending%')
        OR (dcs.`record_status` LIKE '%pending%')
        OR (`rep_name` LIKE '%pending%')
        OR (dcs.`request_date` LIKE '%pending%')
        OR (dcs.`approval_date` LIKE '%pending%')
        OR (dcs.`approved_by` LIKE '%pending%')
        OR (dcs.`comments` LIKE '%pending%')
        OR (dcs.`commission_percentage` LIKE '%pending%')
        OR (dcs.`commission_rep_number` LIKE '%pending%')
        OR (dcs.`customer_part_number` LIKE '%pending%')
        OR (dcs.`distributor_who_is_purchasing` LIKE '%pending%')
        OR (dcs.`engineering_design_qualification` LIKE '%pending%')
        OR (dcs.`estimated_annual_usage` LIKE '%pending%')
        OR (dcs.`id` LIKE '%pending%')
        OR (`internal_part_number` LIKE '%pending%')
        OR (dcs.`origin_information` LIKE '%pending%')
        OR (dcs.`production_timeframe` LIKE '%pending%')
        OR (dcs.`project_engineer` LIKE '%pending%')
        OR (dcs.`purchase_location` LIKE '%pending%')
        OR (dcs.`quote_effective_date` LIKE '%pending%')
        OR (dcs.`record_creator_identifier` LIKE '%pending%')
        OR (`regional_manager` LIKE '%pending%')
        OR (`rep_contact_name` LIKE '%pending%')
        OR (`rep_email_address` LIKE '%pending%')
        OR (dcs.`sales_code` LIKE '%pending%')
        OR (`sample_number` LIKE '%pending%')
        OR (dcs.`shipping_location` LIKE '%pending%')
        OR (dcs.`split_design` LIKE '%pending%'))
ORDER BY main_designin.id DESC
LIMIT 50 OFFSET 0;
Leave a Comment