Re: What's the Access equivalent for this SQL Server query?



Umm, then maybe you should include all the information in your post??
I see that you've posted on Google Groups or some other forum and
you've made the assumption that everyone does the same. Most people
receive these messages through a news reader and therefore don't even
look at your original post because it's in another thread. Keep your
posts about one topic in one thread and that'll keep people all on the
same page.

Now, to your question.

SELECT cancelled
FROM (
SELECT TOP 1 cancelled
FROM tbl_orders
WHERE id_emp = 20
ORDER BY ID DESC)
WHERE cancelled = 0

The subquery selects the most recent cancelled and the query will only
return one record if the subquery returns a true value. I wouldn't
waste the server's time with this though. I would only use the
subquery and let the client handle that itty-bitty check.

Cheers,
Jason Lepack

On Apr 9, 7:27 am, "Oscar" <o...@xxxxxxxxx> wrote:
MH,

You're missing a lot man.

First of all, I need to find the latest entry in the table (ORDER BY ID
DESC) for the specific employee.
After that I need to verify whether the value of the field cancelled=0. This
all needs to be done within one query.

Oscar

"MH" <n...@xxxxxxxxx> schreef in berichtnews:e0rkTkpeHHA.3960@xxxxxxxxxxxxxxxxxxxxxxx



SELECT cancelled
FROM tblOrders
WHERE ID_emp=20 AND cancelled=0

Not sure what the subquery is all about, unless I'm missing something?

MH

"Oscar" <o...@xxxxxxxxx> wrote in message
news:eLRK3loeHHA.5044@xxxxxxxxxxxxxxxxxxxxxxx
What's the Access equivalent for the SQL Server query :

"SELECT cancelled FROM (SELECT cancelled FROM tblOrders WHERE ID_emp=20
ORDER BY ID DESC) WHERE cancelled=0"

The compiler fires an 'Error in FROM clause'- Hide quoted text -

- Show quoted text -


.



Relevant Pages

  • Re: Display records based on count value of one field
    ... The subquery idea never entered my head. ... pointer to the correct forum to use.... ... you can easily build a query that has a common syntax. ...
    (microsoft.public.access.queries)
  • Re: Display records based on count value of one field
    ... I spotted the need for that change when I ran the query on my full table. ... The subquery idea never entered my head. ... pointer to the correct forum to use.... ... you can easily build a query that has a common syntax. ...
    (microsoft.public.access.queries)
  • Re: Jet SQL and Virtual tables/subqueries qiestions
    ... subquery, but it's curious... ... repeated trips through the Query Editor's "graphical" side did ... The Jet Expression Evaluator (what functions & stuff are actually ... within brackets within the query. ...
    (microsoft.public.access.queries)
  • RE: Display most recent comment in report
    ... There are parentheses around the subquery! ... I'm not sure just what you are doing, but the SQL statement is a query; ... FROM Projects INNER JOIN [Communications Log] AS CL1 ... NoteDate and Notes as their ControlSource properties. ...
    (microsoft.public.access.gettingstarted)
  • Re: Mangled, with a difference
    ... My experience with this subquery as a "table" in SQL in ACCESS (where ACCESS ... query will stop working if I create the query, save it, close it (and ACCESS ... I can't say that I've noted that the mangling differs on different PCs, ... inside the square brackets Access added which are themselves inside square ...
    (microsoft.public.access.queries)