Solved

Easy bit of SQL

Posted on 2011-02-25
8
258 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:rawinnlnx9
ID: 34984383
Shoot, blew my query. The right answer is first.
0
 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MS Access Query Question 2 36
Runtime Error -2147467259 (80004005) 7 50
ORDER BY 7 38
Having 'UserName' as a field name - seems to be causing issues 9 28
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

733 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