Query to Match Values (1 Viewer)

tmyers

Well-known member
Local time
Today, 15:54
Joined
Sep 8, 2020
Messages
1,090
I have not done a query quite like this before so could use a little help. I know the field names I am about to show are awful but I have no control over them so don't beat me up too badly.

Goal:
Find all [Sales Register #] where [Extened Price] (yes that is spelled wrong, I know) matches itself in tblTicketDetails while showing [Customer #] to find all orders that were billed under one [Sales Register #] then rebilled under a new one (and possibly changed customers in the process).

I know I need to inner join the table on itself via [Extened Price] but the couple iterations I have tried have all timed out. What am I missing in this?
SQL:
SELECT tblTicketDetails.[Customer #], tblTicketDetails.[Sales Register #], tblTicketDetails.[Extened Price]
FROM tblTicketDetails AS tblTicketDetails_1 INNER JOIN tblTicketDetails ON tblTicketDetails_1.[Extened Price] = tblTicketDetails.[Extened Price];
 

plog

Banishment Pending
Local time
Today, 14:54
Joined
May 11, 2011
Messages
11,646
I don't know that you do need to JOIN the table back to itself. An aggreate subquery might do the trick:

Code:
SELECT SalesRegister, CustomerNum, ExtendedPrice
FROM YourTable
GROUP BY SalesRegister, CustomerNum, ExtendedPrice
HAVING COUNT(ExtendedPrice]>1

That's going to return all the SalesRegister/CustomerNum/ExtendedPrice permutations that occur multiple times in your table.

That will solve what you described, but not certain it will be what you want. I don't understand your data, so words isn't the best way to convey what you want to us. The best way to do that is with data. 2 sets:

A. STarting data from your database. Include table and field names and enough records to cover all cases.

B. Expected results of A. Show us what data you expect your query to return when you feed it data from A.

Again, 2 sets of data--starting and expected. No need for explanations the data will speak for itself.
 

Users who are viewing this thread

Top Bottom