Solved

Easy bit of SQL

Posted on 2011-02-25
8
229 Views
Last Modified: 2012-05-11
Take a table with 2 fields :
ProductCode
UniqPrice

select all records with UniqPrice=Y where the ProductCode occurs more than once.

(This is an error checking mechanism.  I want to ensure each ProductCode occurs only once with the UniqPrice flag =Y)
0
Comment
Question by:Patrick O'Dea
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 300 total points
ID: 34984339
Like so:

SELECT Table1.ProductCode
FROM Table1
WHERE (((Table1.UniqPrice)="Y"))
GROUP BY Table1.ProductCode
HAVING (((Count(Table1.ProductCode))>1));


mx
0
 
LVL 9

Assisted Solution

by:rawinnlnx9
rawinnlnx9 earned 100 total points
ID: 34984341
Select * From Table1 WHERE UniqPrice='Y' AND ProductCode HAVING COUNT(*) > 1
0
 
LVL 33

Assisted Solution

by:jppinto
jppinto earned 100 total points
ID: 34984353
SELECT Count(YourTableName.ProductCode) AS CountOfProductCode, YourTableName.ProductCode
FROM [YourTableName]
WHERE (((YourTableName.UniqPrice)=Y))
GROUP BY YourTableName.ProductCode
HAVING (((Count(YourTableName.ProductCode))>1));
0
 
LVL 9

Expert Comment

by:rawinnlnx9
ID: 34984383
Shoot, blew my query. The right answer is first.
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 33

Expert Comment

by:jppinto
ID: 34984399
"the right answer is first" ....and last! :)
0
 
LVL 75
ID: 34984468
".and last! :)"
2 minutes later :-)

mx
0
 

Author Closing Comment

by:Patrick O'Dea
ID: 34984493
Thanks
0
 
LVL 75
ID: 34984536
21Dewsbury: ... with all due respect, there was no need for a Split here
And the Assist by rawinnlnx9 does not even work.
And jppinto posted the same thing I did

mx
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now