J'essaie d'obtenir la différence entre les instructions 2 select
.Obtenez la différence entre deux instructions SELECT
Voici la première select
:
SELECT 1
SELECT *
FROM h_log_material
LEFT JOIN h_log_stkpnl
ON h_log_stkpnl.MODULE_UNIQUE_ID = h_log_material.MODULE_UNIQUE_ID
where
h_log_material.WO_ID='E11TMB7M05'
and h_log_material.mtrl_type='BL'
sortie est 4917
SELECT 2
Voici deuxième select
:
SELECT *
FROM h_log_material
LEFT JOIN h_log_stkpnl
ON h_log_stkpnl.MODULE_UNIQUE_ID = h_log_material.MODULE_UNIQUE_ID
where
h_log_material.WO_ID='E11TMB7M05'
and h_log_material.mtrl_type='BL'
and h_log_stkpnl.op_id like '%STOCK-IN%'
sortie est 4870
Je voudrais obtenir la différence SELECT 1 - SELECT 2
Comme sortie j'ai besoin des lignes qui ne sont pas sélectionnez 2.
J'ai essayé ceci mais il renvoie 0.
SELECT *
FROM h_log_material
LEFT JOIN h_log_stkpnl
ON h_log_stkpnl.MODULE_UNIQUE_ID = h_log_material.MODULE_UNIQUE_ID
where
h_log_material.WO_ID='E11TMB7M05'
and h_log_material.mtrl_type='BL'
and not exists
(SELECT *
FROM h_log_material
LEFT JOIN h_log_stkpnl
ON h_log_stkpnl.MODULE_UNIQUE_ID = h_log_material.MODULE_UNIQUE_ID
where
h_log_material.WO_ID='E11TMB7M05'
and h_log_material.mtrl_type='BL'
and h_log_stkpnl.op_id like '%STOCK-IN%')
Ce travail, en tant que sortie j'ai besoin des lignes qui ne sont pas sélectionnez 2. –
@John - Pourquoi tous vos exemples de requêtes en utilisant 'SELECT COUNT (*)' alors? Dans tous les cas 'et n'existe pas (SELECT count (*) ...' ne fonctionnera pas car 'COUNT (*)' retournera toujours quelque chose Même si 0. Que faire si vous essayez 'et n'existe pas (SELECT * ... ' –
Désolé j'ai oublié enlevé * de SQL.J'ai testé quelque chose –