En TYPE NUMBERS.sql

Материал из MstarProject Manual
Перейти к: навигация, поиск

/* Display of the car types list for a specified KBA number (used in Germany) */

/* TYP_ID - Car type number */

/* TYP_MMT_CDS_TEXT - the full name of the car (brand/model/type) */

/* TYP_PCON_START - YYYYMM: type release Year/month */

/* TYP_PCON_END - YYYYMM: type production termination Year/month (NULL - unlimited) */

/* TYP_CCM - Engine capacity (cc) */

/* TYP_CCM_TAX - Engine capacity (cc) ("effective capacity"?) */

/* TYP_KW_FROM - Engine power (kW): FROM */

/* TYP_KW_UPTO - Engine power (kW): UPTO (NULL - unlimited) */

/* TYP_HP_FROM - Engine power (hp): FROM */

/* TYP_HP_UPTO - Engine power (hp): UPTO (NULL - unlimited) */

/* TYP_CYLINDERS - Number of cylinders */

/* ENG_CODE - Engine code */

/* TYP_ENGINE_DES_TEXT - Engine type */

/* TYP_FUEL_DES_TEXT - Fuel type */

/* TYP_BODY_DES_TEXT - Type of body design */

/* TYP_AXLE_DES_TEXT - Type of axle design (for trucks)*/

/* TYP_MAX_WEIGHT - Tonnage (for trucks)*/

SET @KBA_NR1 = '9101'; /* VOLVO V70 II wagon (P80_) 2.4 D5 [2001/08-...] */
SET @KBA_NR2 = '853';
SET @KBA_NR = CONCAT(@KBA_NR1, @KBA_NR2);
SET @LNG_ID = 16; /* 1 - German; 16 - Russian */
SELECT	TYP_ID,	MFA_BRAND,	DES_TEXTS7.TEX_TEXT AS MOD_CDS_TEXT,	DES_TEXTS.TEX_TEXT AS TYP_CDS_TEXT,	TYP_PCON_START,	TYP_PCON_END,	TYP_CCM,	TYP_KW_FROM,	TYP_KW_UPTO,	TYP_HP_FROM,	TYP_HP_UPTO,	TYP_CYLINDERS,	ENGINES.ENG_CODE,	DES_TEXTS2.TEX_TEXT AS TYP_ENGINE_DES_TEXT,	DES_TEXTS3.TEX_TEXT AS TYP_FUEL_DES_TEXT,	IFNULL(DES_TEXTS4.TEX_TEXT, DES_TEXTS5.TEX_TEXT) AS TYP_BODY_DES_TEXT,	DES_TEXTS6.TEX_TEXT AS TYP_AXLE_DES_TEXT,	TYP_MAX_WEIGHT
FROM	           TYPE_NUMBERS
INNER JOIN TYPES ON TYP_ID = TYN_TYP_ID
INNER JOIN COUNTRY_DESIGNATIONS ON COUNTRY_DESIGNATIONS.CDS_ID = TYP_CDS_ID
INNER JOIN DES_TEXTS ON DES_TEXTS.TEX_ID = COUNTRY_DESIGNATIONS.CDS_TEX_ID
INNER JOIN MODELS ON MOD_ID = TYP_MOD_ID
INNER JOIN MANUFACTURERS ON MFA_ID = MOD_MFA_ID
INNER JOIN COUNTRY_DESIGNATIONS AS COUNTRY_DESIGNATIONS2 ON COUNTRY_DESIGNATIONS2.CDS_ID = MOD_CDS_ID
INNER JOIN DES_TEXTS AS DES_TEXTS7 ON DES_TEXTS7.TEX_ID = COUNTRY_DESIGNATIONS2.CDS_TEX_ID
LEFT JOIN DESIGNATIONS ON DESIGNATIONS.DES_ID = TYP_KV_ENGINE_DES_ID
LEFT JOIN DES_TEXTS AS DES_TEXTS2 ON DES_TEXTS2.TEX_ID = DESIGNATIONS.DES_TEX_ID
LEFT JOIN DESIGNATIONS AS DESIGNATIONS2 ON DESIGNATIONS2.DES_ID = TYP_KV_FUEL_DES_ID
LEFT JOIN DES_TEXTS AS DES_TEXTS3 ON DES_TEXTS3.TEX_ID = DESIGNATIONS2.DES_TEX_ID
LEFT JOIN LINK_TYP_ENG ON LTE_TYP_ID = TYP_ID
LEFT JOIN ENGINES ON ENG_ID = LTE_ENG_ID
LEFT JOIN DESIGNATIONS AS DESIGNATIONS3 ON DESIGNATIONS3.DES_ID = TYP_KV_BODY_DES_ID
LEFT JOIN DES_TEXTS AS DES_TEXTS4 ON DES_TEXTS4.TEX_ID = DESIGNATIONS3.DES_TEX_ID
LEFT JOIN DESIGNATIONS AS DESIGNATIONS4 ON DESIGNATIONS4.DES_ID = TYP_KV_MODEL_DES_ID
LEFT JOIN DES_TEXTS AS DES_TEXTS5 ON DES_TEXTS5.TEX_ID = DESIGNATIONS4.DES_TEX_ID
LEFT JOIN DESIGNATIONS AS DESIGNATIONS5 ON DESIGNATIONS5.DES_ID = TYP_KV_AXLE_DES_ID
LEFT JOIN DES_TEXTS AS DES_TEXTS6 ON DES_TEXTS6.TEX_ID = DESIGNATIONS5.DES_TEX_ID
WHERE	TYN_SEARCH_TEXT = @KBA_NR AND	TYN_KIND = 1 AND	COUNTRY_DESIGNATIONS.CDS_LNG_ID = @LNG_ID AND	COUNTRY_DESIGNATIONS2.CDS_LNG_ID = @LNG_ID AND
(DESIGNATIONS.DES_LNG_ID IS NULL OR DESIGNATIONS.DES_LNG_ID = @LNG_ID) AND
(DESIGNATIONS2.DES_LNG_ID IS NULL OR DESIGNATIONS2.DES_LNG_ID = @LNG_ID) AND
(DESIGNATIONS3.DES_LNG_ID IS NULL OR DESIGNATIONS3.DES_LNG_ID = @LNG_ID) AND
(DESIGNATIONS4.DES_LNG_ID IS NULL OR DESIGNATIONS4.DES_LNG_ID = @LNG_ID) AND
(DESIGNATIONS5.DES_LNG_ID IS NULL OR DESIGNATIONS5.DES_LNG_ID = @LNG_ID)
ORDER BY	MFA_BRAND,	MOD_CDS_TEXT,	TYP_CDS_TEXT,	TYP_PCON_START,	TYP_CCM;