Adding more criteria to an SQL query...

N

Noozer

I need to add more criteria to a query that I am currently using... I've
figure out the logic, but can't create a single SQL statement that does what
I need.

The current SQL statement is:

SELECT * FROM Tickets LEFT JOIN ( SELECT TicketKeyLink, COUNT(*) AS
ActionCount FROM Actions GROUP BY Actions.TicketKeyLink) AS b ON
Tickets.TicketKey=b.TicketKeyLink;

I want to replace the first reference to Tickets in the above query with
another query. I have this query created and it does return the results I
want. I just need to add it to the above query. This is the query:

SELECT * FROM Tickets INNER JOIN ( SELECT * FROM Actions WHERE
RepGroup="MyGroup") AS c ON Tickets.TicketKey=c.TicketKeyLink;

How can I change the first query to include the second query... like:

SELECT * FROM (new query) LEFT JOIN ( SELECT.... etc.
 
D

David Lloyd

I may not understand exactly your situation, however, you can reference the
name of a query in a FROM statement in Access. Therefore if your second
query is a named (saved) query in Access, you should be able to reference
its name just as if it were a table and use it in your first query.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


I need to add more criteria to a query that I am currently using... I've
figure out the logic, but can't create a single SQL statement that does what
I need.

The current SQL statement is:

SELECT * FROM Tickets LEFT JOIN ( SELECT TicketKeyLink, COUNT(*) AS
ActionCount FROM Actions GROUP BY Actions.TicketKeyLink) AS b ON
Tickets.TicketKey=b.TicketKeyLink;

I want to replace the first reference to Tickets in the above query with
another query. I have this query created and it does return the results I
want. I just need to add it to the above query. This is the query:

SELECT * FROM Tickets INNER JOIN ( SELECT * FROM Actions WHERE
RepGroup="MyGroup") AS c ON Tickets.TicketKey=c.TicketKeyLink;

How can I change the first query to include the second query... like:

SELECT * FROM (new query) LEFT JOIN ( SELECT.... etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top