Skip to Content
0
Former Member
Mar 03, 2009 at 01:08 PM

query gives error

24 Views

Hi All,

I am encountering such problems time and again while running such queries in Query wizard : following is my query and it runs if I dont add the 'where' clause.

SELECT T0.[CardName] as 'Customer Name' , T0.[NumAtCard], T0.[DocNum], T1.[ItemCode], T1.[Dscription], T1.[Quantity], T1.[Price], T0.[DocTotal], T1.[StockPrice] as 'Final ItemCost',
   convert(varchar,(select sum(isnull(T2.stockprice * T2.Quantity,0)) from dbo.DLN1 T2 where T1.docentry = T2.docentry))  as [Total Item Cost],
(T1.[Quantity] * T1.[Price])-(T1.[StockPrice] * T1.[Quantity])  as 'Profit on Sale of Item', T1.BaseRef as 'Sales Order No.'  FROM dbo.ODLN T0  INNER JOIN dbo.DLN1 T1 ON T0.DocEntry = T1.DocEntry

if at the end , I add

 where T1.BaseRef  = [%0]

or

where T1.BaseRef  = Isnull([%0], T1.Baseref)

it gives me the error 'Must specify the table to select from'.

what is that I am doing wrong?

thanks,

Binita