Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
What is worng in the query of mine?

My query as follows:
SQL
select first.MaskedOldCardNo,first.OldCardNo,first.OldAccountNo,first.ODUtilizedAmount,first.ODLimit,first.ODBalance
from                   
(SELECT top 1 [dbo].[fnMaskCardNo](E.CardNo)as MaskedOldCardNo,E.CardNo as OldCardNo,      
E.AccountNo as OldAccountNo,select ODUtilizedAmount from (select top 1 SASR.OdUtilizationAmount as ODUtilizedAmount from SalaryAdvanceSnapShotSpecificationReport
SASR inner join  Employee E on SASR.CardNo=E.CardNo
 where CorporateId=@CorporateId and EmpId=@EmpId AND IsDeleted=1
 order by SASR.CreatedDate desc),SA.SA_Limit as ODLimit,dbo.fnGetODBalance(E.EmpId,E.CorporateId,E.CardNo) as ODBalance  FROM EMPLOYEE E inner join                 
SalaryAdvanceMaster SA on                  
SA.C3EmpRegId=E.C3EmpRegId   
inner join  dbo.SalaryAdvanceSnapShotSpecificationReport  SASR  
ON SASR.CardNo=E.CardNo           
WHERE E.EmpId=@EmpId and E.CorporateId=@CorporateId and E.SalaryAdvance=1 and E.IsDeleted=1  ORDER by E.DeletedDate desc)first
Posted
Updated 6-Mar-14 20:25pm
v2
Comments
Maciej Los 7-Mar-14 2:32am    
Please, be more specific and provide more details about your issue. We can't read in your mind...
OriginalGriff 7-Mar-14 3:43am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
We have no idea what you expect it to do, let alone what it does do!
Use the "Improve question" widget to edit your question and provide better information.

1 solution

From http://msdn.microsoft.com/en-us/library/c5x9a05a%28v=vs.80%29.aspx:
Quote:
In the FROM clause, each subquery requires an alias.
So each closing parenthesis needs to be followed by AS ...

I'm no SQL expert (I didn't even know you could have a subquery in the FROM clause until a few minutes ago), so there may be more problems that I haven't spotted.
 
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