I want to select data from the table if and only if the unique mobile numbers are equal to the total number of rows in the table (i.e. we do not have two different people with the same mobile number and / or we do not have a row with zero values in the column mobile number), where there is a specific area code, for example 4817.
At the moment, I have a request below (which does not work with AND restriction). Does anyone have any tips on how to do this?
SELECT
MOB_NUM AS MOBILE_NUMBER,
NAME AS NAME,
AREA_CODE AS AREA_CODE
FROM DB_PHONEBOOK DBP
WHERE DBP.AREA_CODE = 4817
AND (COUNT(DISTINCT DBP.MOB_NUM ) = COUNT(DBP.MOB_NUM))
source
share