Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am doing work on revenues some taccounts missing in that.

What I have tried:

In table I need to check that accounts are missing.
SQL
select count (*) from CTInterface
I tried this query getting 85 accounts but
SQL
select count (*) from revenues where accttype='ct'
getting only 73 accounts.

I need to find the 12 missing accounts in table
Posted
Updated 7-Oct-20 22:09pm
v2
Comments
Sandeep Mewara 8-Oct-20 3:02am    
It's far too less information to have a concrete answer here. What accounts, whats missing, what is the table structure, what query you wrote and struggling with?
mounika mouni 8-Oct-20 3:13am    
hI sandeep,
in table i need to check that accounts are missing.
select count (*) from CTInterface i tried this query getting 85 accounts
but select count (*) from revenues where accttype='ct' getting only 73 accounts.

i need to find the 12 missing accounts in table
Richard MacCutchan 8-Oct-20 3:46am    
If you can extract all the accounts and you can extract the set with 'ct' (whatever that means) then it is a simple matter to compare the two sets to see which are the missing ones.
mounika mouni 8-Oct-20 5:02am    
can you plz explain briefly how to extract

from CTInterface getting 85 ROWS and from revenues tables getting 73 ROWS .need to find misiing columns

Try:
SQL
SELECT *
FROM CTInterface As A
WHERE Not Exists
(
    SELECT 1
    FROM revenues As R
    WHERE R.accttype='ct'
    AND R.ACCOUNTNUMBERCOLUMNHERE = A.ACCOUNTNUMBERCOLUMNHERE
)
You will need to replace the ACCOUNTNUMBERCOLUMNHERE column names with the correct column names from your tables.
 
Share this answer
 
Comments
Maciej Los 8-Oct-20 4:10am    
5ed!
If i understand you well, you want to get entries from CTInterface table which have no related data in revenues table. You need to use LEFT JOIN.

SQL
select cti.*
from CTInterface cti LEFT JOIN revenues rev ON cti.<PrimaryKey> = rev.<ForeignKey> 
WHERE rev.accttype IS NULL


For further details, please see: Visual Representation of SQL Joins[^]

Note: you have to replace value between <...> with proper field name.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900