Subquery is Field/Column in Access

Is this logic allowed in MS ACCESS?

EXAMPLE:
select A.field1, A.field2, (select sum(field) from table B where B.ID=A.ID and B.status =1) as Totals from table A
group by A.field1, A.field2
patriotpacerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill RossProgrammerCommented:
This subselect syntax is fine.

Create a new query and select SQL, drop in the code.

Make sure table names and field names are correct.

Regards,

Bill
0
mbizupCommented:
I dont think that syntax will work out for you in Access.

Try this variation:

select A.Field1, A.Field2, sum(field) AS Totals
FROM  Table1 A INNER JOIN  Table2 B ON  B.ID=A.ID
WHERE B.status =1
group by A.Field1, A.Field2

Open in new window

0
patriotpacerAuthor Commented:
>>Create a new query and select SQL, drop in the code.

I have.  Very basic.  Won't work.


>>I dont think that syntax will work out for you in Access.

Problem is the field where you have the SUM needs to have specific criteria on it (status=1).

Ultimately I need a row of fields that each will have their own criteria.  

I have a related, but separate question, on this topic.  Again, this question is if it's possible.  The other question is to fix my query.

http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_28240898.html
0
mbizupCommented:
Did you see my comment at http:#a39497546 ?  I think we might have cross-posted.

I don't think that the syntax you are trying is going to work in Access.

The inner join syntax I posted in my last comment is a common approach that I think will get the results you are looking for.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
patriotpacerAuthor Commented:
>>I don't think that the syntax you are trying is going to work in Access.

I have in way, no manner been able to get it to work.

Going to assume you're correct.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.