How can I select unique records from Access based on two criteria

40 pts.
Tags:
Microsoft Access
SQL
SQL queries
I need to do the following:
SQL = "select amount, count(amount) from table1 group by amount having count(*) =1"
This returns all unique records, but I need to add another criteria to that statement ie: I need to select all unique records only if a second value is met as well! This is what I had in mind but it doesn't work, I have tried so many variations!
SQL = "select amount, count(amount) from table1 group by amount having count(*) = 1 And msgsent = 1"
So I need to get all unique amounts but only if msgsent = 1 and not = 0 Basicly I need to verify against two fields! Can this be done?

Answer Wiki

Thanks. We'll let you know when a new response is added.

SQL = “select amount, count(amount) from table1 where msagent = 1
group by amount
having count(*) = 1 And msgsent = 1″
will take care of your issue.

Regards,
Sarfaraz Ahmed
<a href=”http://findsarfaraz.blogspot.com”>MS Excel help</a>

Hi,

Take this SQL

select amount, count(amount) from table1
where msagent = 1
group by amount
having count(*) = 1

Regards,
Siva

Hi Sarfaraz

I tried your solution and get the following run time error:

You tried to execute aquery that does not include the specified expression ‘count(*)=1 And msgsent=1′ as part of an aggregate function

Regards,
Grant

Hi Siva,

I tried your solution and it works great, thanks alot

Regards,
Grant

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following