Link to home
Start Free TrialLog in
Avatar of thao-nhi
thao-nhi

asked on

How to output boolean to a query in in Access 2010

I have a table with boolean fields

[ItemID] as  text
[Qty] as number
[InStock] as boolean
[Call_Back] as boolean

How do I build a query to show how many times the Item is in stock and not in stock. I want to put these results 1 after the other in the query. Thanks
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

try this query

select itemid, sum(iif([instock]=-1,1,0)) as [In Stock] , sum(iif([instock]=0,1,0)) as [Not In Stock]
from tablex
group by itemid
Avatar of thao-nhi
thao-nhi

ASKER

I  got an error message " Duplicate output alias as Order_Placed" when run the query as below

SELECT [PRODUCT INQUIRY].Part_ID, sum(iif([Order_Placed]=-1,1,0)) as [Order_Placed], sum(iif([Order_Placed]=0,1,0)) as [Order_Placed]
from [PRODUCT INQUIRY]
GROUP BY [PRODUCT INQUIRY].Part_ID;
error message
Circular reference caused by alias Order_Placed in query definitions' select list


SELECT [PRODUCT INQUIRY].Part_ID, sum(iif([Order_Placed]=-1,1,0)) as [Order_Placed], sum(iif([Order_Placed]=0,1,0)) as [NO Order_Placed]
from [PRODUCT INQUIRY]
GROUP BY [PRODUCT INQUIRY].Part_ID;
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial