tags:

views:

9

answers:

0

I am working with the datasets of .net I have an Oracle Query which is working fine . but I copy the query as sql statement within Table Adapter wizard and after I clicked the Query Builder button ,there is SQL syntax error. The query is below:

SELECT lead_id, NAME, ADDRESS, CITY, EMAIL, PHONE, PINCODE, STATE, QUALIFICATION, DOB, status
FROM (SELECT l.lead_id, l.NAME, l.ADDRESS, l.CITY, l.EMAIL, l.PHONE, l.PINCODE,
l.STATE, l.QUALIFICATION,
l.DOB, 
CASE 
WHEN s.status IS NULL 
             THEN 'Not Updated !' 
ELSE s.status 
END status,
row_number() over(PARTITION BY l.lead_id
                   ORDER BY t .CREATED_DATE DESC) rn
FROM   LEADS l JOIN  Leads lc ON l.USER_ID = lc.USER_ID AND l.USER_ID = :iuser_id 
AND(l.CREATED_DATE BETWEEN (TO_DATE(:ifrom_date , 'dd-mm-yyyy')
                           )
                  AND (TO_DATE (:ito_date, 'dd-mm-yyyy' )
                     ))
LEFT JOIN   LEADTRANSACTION t ON l.lead_id = t .lead_id
LEFT JOIN STATUS s ON s.STATUS_ID = t .STATUS_ID) WHERE rn = 1;