Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
select collection_date,Collection_time,Branch_code,company_id,rec_series,receipt_number,FirstSet.receipt,account_number,account_type,collected_amount,agent_code
from (select collection_date,Collection_time,Branch_code,company_id,rec_series,receipt_number,receipt,account_number,account_type,collected_amount,agent_code
from missing where collection_date between '2016-02-19' AND '2016-02-23'  and rec_series ='SP18')as FirstSet    
inner join
 (SELECT  TOP 1
        receipt + 1
FROM    misseddata mo
WHERE   NOT EXISTS
(
        SELECT  NULL
        FROM    misseddata mi 
        WHERE   mi.receipt = mo.receipt + 1
)
        group BY receipt ) 


What I have tried:

joined two table to get the missing record and getting the error message
( Msg 102, Level 15, State 1, Line 14
Incorrect syntax near ')'. Dont na where i went wrong
Posted
Updated 23-Apr-20 9:05am
Comments
super 29-Feb-16 9:05am    
Which table does mi and mo represent?
alia007 1-Mar-16 0:31am    
both are same table with alias

1 solution

You need to alias and join the table at the end.

It's like you have this:
SQL
SELECT *
FROM table1
INNER JOIN table2 


You have no join clause at the end.
 
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