SELECT
QUOTE.ENTITY_ID,
QUOTE.QUOTE_DATE,
QUOTE.EXPIRATION_DATE,
QUOTE.WON_LOSS_DATE,
CASE (QUOTE.STATUS) WHEN 'W' THEN 'Won' WHEN 'P' THEN 'Printed' WHEN 'A' THEN 'InHouse' END AS Status,
QUOTE.ID,
QUOTE.NAME,
QUOTE.SALESREP_ID,
QUOTE.WON_LOSS_REASON,
QUOTE_PRICE.QUOTE_ID,
QUOTE_PRICE.QTY,
QUOTE_PRICE.UNIT_PRICE,
QUOTE_LINE.PRODUCT_CODE,
QUOTE_LINE.PART_ID,
YEAR(QUOTE.QUOTE_DATE) AS Year,
MONTH(QUOTE.QUOTE_DATE) AS Month,
PART.USER_8, QUOTE_LINE.LINE_NO,
QUOTE_LINE.CUSTOMER_PART_ID,
COALESCE (QUOTE_LINE.PART_ID, QUOTE_LINE.CUSTOMER_PART_ID, QUOTE_LINE.DESCRIPTION) AS ISNullPartID,
QUOTE_LINE.DESCRIPTION,
QUOTE_PRICE.QTY * QUOTE_PRICE.UNIT_PRICE AS NetPrice,
CASE WHEN isnull(PART.USER_8, '') = '' THEN 'WORK ORDER PN' ELSE PART.USER_8 END AS User_8PartType
FROM QUOTE_PRICE INNER JOIN
QUOTE_LINE ON QUOTE_PRICE.QUOTE_ID = QUOTE_LINE.QUOTE_ID AND QUOTE_PRICE.QUOTE_LINE_NO = QUOTE_LINE.LINE_NO INNER JOIN
QUOTE ON QUOTE_LINE.QUOTE_ID = QUOTE.ID LEFT OUTER JOIN
PART ON QUOTE_LINE.PART_ID = PART.ID
WHERE (YEAR(QUOTE.QUOTE_DATE) IN (@Year)) AND (MONTH(QUOTE.QUOTE_DATE) IN (@Month))
ORDER BY QUOTE_PRICE.QUOTE_ID
|