Click here to Skip to main content
15,888,251 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everybody,

i have created a query in access. query is below

SQL
SELECT Br.BranchName, SI.Vehicle, SI.PartNo, SI.Description, IIf(IsNull((SELECT SUM(OB) FROM [StockItemOB] where BranchName=Br.BranchName AND PartNo=SI.PartNo)),0,(SELECT SUM(OB) FROM [StockItemOB] where BranchName=Br.BranchName AND PartNo=SI.PartNo)) AS OB, IIf(IsNull((SELECT SUM(Qty) FROM [PurchaseTransaction] where BranchName=Br.BranchName AND PartNo=SI.PartNo)),0,(SELECT SUM(Qty) FROM [PurchaseTransaction] where BranchName=Br.BranchName AND PartNo=SI.PartNo)) AS Pur, IIf(IsNull((SELECT SUM(Qty) FROM [StockTransfer] where DestinationBranch=Br.BranchName AND PartNo=SI.PartNo)),0,(SELECT SUM(Qty) FROM [StockTransfer] where DestinationBranch=Br.BranchName AND PartNo=SI.PartNo)) AS StkIn, IIf(IsNull((SELECT SUM(Qty) FROM [StockTransfer] where SourceBranch=Br.BranchName AND PartNo=SI.PartNo)),0,(SELECT SUM(Qty) FROM [StockTransfer] where SourceBranch=Br.BranchName AND PartNo=SI.PartNo)) AS StkOut, IIf(IsNull((SELECT SUM(ET.Quantity) FROM [EstimateMaster] AS EM INNER JOIN EstimateTransaction AS ET ON EM.ID = ET.EstimateID where EM.BranchName=Br.BranchName AND ET.PartNo=SI.PartNo)),0,(SELECT SUM(ET.Quantity) FROM [EstimateMaster] AS EM INNER JOIN EstimateTransaction AS ET ON EM.ID = ET.EstimateID where EM.BranchName=Br.BranchName AND ET.PartNo=SI.PartNo)) AS Sal, IIf(IsNull((SELECT AVG(ET.Rate) FROM [EstimateMaster] AS EM INNER JOIN EstimateTransaction AS ET ON EM.ID = ET.EstimateID where EM.BranchName=Br.BranchName AND ET.PartNo=SI.PartNo)),0,(SELECT AVG(ET.Rate) FROM [EstimateMaster] AS EM INNER JOIN EstimateTransaction AS ET ON EM.ID = ET.EstimateID where EM.BranchName=Br.BranchName AND ET.PartNo=SI.PartNo)) AS Rate
FROM StockItem AS SI, Branch AS Br
ORDER BY SI.Vehicle, SI.PartNo;


From above query when i have created another query, then i m getting error . query is below
SQL
SELECT ViewItemStock2.BranchName, ViewItemStock2.Vehicle, ViewItemStock2.PartNo, ViewItemStock2.Description, ViewItemStock2.Sal
FROM ViewItemStock2
where ViewItemStock2.Sal >0
order by ViewItemStock2.Vehicle, ViewItemStock2.PartNo
Posted
Comments
Sinisa Hajnal 19-Nov-14 2:24am    
WHAT error? Please spend some time and format first query properly it is impossible to read. What do you mean "from above query I've created..." you mean you took a part of it and tried to run it separately?

Or do you mean the first query is view? Can views have order by in access?

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