applying any condition. This in turn means that all tuples of a relation specified in FROM clause qualify for being selected for the result of query. Consider the following query with reference to Model-I. ( ) Find out the list of accounts which have been debited ( Model-I ) SELECT DISTINCT Debit As Code FROM vouchers; (Model-II) AccCode As Code vouchers vType = ; UNION Details.Code vouchers, Details vType = AND vouchers.vNo = Details.vNo; Save above query as DebitAccounts, and thereafter execute another query as given below to get the final results.
SELECT DISINCT * Debit Accounts ; ( ) Find out the list of accounts which have been credited ( Model-I ) SELECT DISTINCT Credit As Code vouchers ; ( Model-II ) AccCode As Code vouchers Vtype = ; UNION Details.Code vouchers, Details vType = AND vouchers.vNo = Details.vNo; Save above query as CreditAccounts, and thereafter execute another query as given below to get the final results. SELECT DISINCT * CreditAccounts; ( ) Find out the list of accounts which have been debited as well as credited ( Model-I ) SELECT DISTINCT Debit As Code vouchers Debit IN (SELECT Credit As Code vouchers); ( Model-II ) SELECT * DebitAccounts Code IN ( SELECT * CreditAccounts) ; Save above solution query as DebitCredit, both for Model-I and Model-II ( ) Find out the list of accounts which have been debited but not credited ( Model-I ) DISTINCT Debit As Code vouchers Debit NOT IN ( SELECT Code DebitCredit) ; ( Model-II ) SELECT * DebitAccounts Code NOT IN (SELECT * DebitCredit) ( ) Find out the list of accounts which have been credited but not debited (Model-I) SELECT DISTINCT Credit As Code vouchers Credit NOT IN ( SELECT Code DebitCredit) ; (Model-II) SELECT * CreditAccounts Code NOT IN ( SELECT * DebitCredit)