Hi Jess,
Try to remove the check *Track Name Autocorrect Info* from
Tools-->Options-->General-->Name Autocorrect Options
Rewrite the query and give the derived table name
----
SELECT *
FROM [SELECT IIf([Q].[accType] in
("A","O","S"),"OP",IIf([Q].[accType]="E","ED",IIf([Q].[accType]="I","IP",[Q
].[accType])))
AS patType, Q.OrdName, Q.CountOfOrdSeq
FROM LABORDER AS Q]. AS DRV_TBL
ORDER BY PatType
----
bye
--
Giorgio Rancati
[Office Access MVP]
"Jess" <
[email protected]> ha scritto nel messaggio
Hi All.
I recently posted a 'cry for help' but didn't get any replies... not
sure why...maybe it wasn't clear but I think it is relevent and easy
for experienced Access developers, so I thought I'd post it here since
it has to do with Nested queries and this guy got a lot of replies:I sucessfully created a query with a nested select and it seems that
Access gave the subquery an alias name: AS [%$##@_Alias]
...ok by me since it worked.
but when I had to go back to add another condition on the iif/in set
"A","O","S"), I got a
syntax error. I tried rebuilding from scratch, the subquery works on
its own but I can't wrap the select * from it.
The query that works:
SELECT *
FROM [SELECT IIf([Q].[accType] in
("A","O","S"),"OP",IIf([Q].[accType]="E","ED",IIf([Q].[accType]="I","IP",[Q
].[accType])))
AS patType, Q.OrdName, Q.CountOfOrdSeq
FROM LABORDER AS Q]. AS [%$##@_Alias]
ORDER BY PatType
For now I will do this in 2 queries but I'm trying to get better at
this!!
thanks,
Jess
giorgio said:
Hi Jon,
if you have some rows with [Company] = NULL the NOT IN operator doesn't
return rows
this works
----
SELECT Clients.ID, Clients.Company, Clients.[Company 2]
FROM Clients
WHERE Clients.[Company 2] Not In
(SELECT [Company] FROM [Clients] WHERE [Company] Is Not Null)
----
however the query with self join is a better way to do this query:
bye
--
Giorgio Rancati
[Office Access MVP]
John said:
It does not give the result i.e. results no records while I know there
should be some. One example is below;
Company ID Company 2
Liffe 5483 Simon Pleydell
Simon Pleydell does not exist in the clients.company field any where in
the table and I have verified this by manually trying to find 'Simon
Pleydell' in the company field. Any ideas why it would not work?
Thanks
Regards
Hi
I have the following query;
SELECT Clients.ID, Clients.Company, Clients.[Company 2]
FROM Clients
WHERE Clients.[Company 2] Not In (SELECT [Company] FROM [Clients])
When I do not use the keyword Not it works but not with keyword Not. Is
this
a bug? I am using access 2000 sp3.
Thanks
Regards
What do you mean it doesn't work? Do you get an error, or does it simply
not give you the results you expect?