Click here to Skip to main content
14,635,191 members
Rate this:
Please Sign up or sign in to vote.
See more:
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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

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


You have no join clause at the end.
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100