I came across a fictitious SQL, i am not sure what is the original intend, it looks like:
SELECT COUNT (*)
INTO miss
FROM billing b
WHERE b.network= network1
and NOT EXISTS (SELECT 1 from vas NV WHERE NV.network =
b.network);
Why is there a select 1, and not exists?
When using the
EXISTSkeyword you need to have a sub-select statement, and only the existence of a row is checked, the contents of the row do not matter.SELECTis a keyword that controls what is inside the columns that are returned.SELECTing1orNV.networkwill return the same number of rows.Therefore you can SELECT whatever you want, and canonical ways to do that include
SELECT NULLorSELECT 1.Note that an alternative to your query is:
(left join fills right-hand columns with
NULLvalues when theONcondition cannot be matched.