I know that I can't actually use the SELECT DISTINCT in a query that includes the primary key value and expect it to remove duplicated values, but I'm looking for that kind of affect.
I have a combo box that is based on a table that has four fields:
AppPermissionID, PK
LoanType_fk
County_fk
Appraiser_fk
This is basically a three-way join table.
Normally, I have the records filtered by both the loan type and the county to get the appraisers that can do appraisals for the selected loan type in the selected county. However, there are certain situations where I want this filter removed. If I simply remove the WHERE clause in the row source of my combo box, then I get each appraiser listed multiple times. I want each appraiser to be listed only once, but the combo box is bound to the AppPermissionID field so I can't just do a SELECT DISTINCT query on the Appraiser_fk field. I'm thinking that I saw a solution one time that used the Count() function, but I can't find it again nor can I figure it out.
4 2603
How do you choose which AppPermissionID you want? If it doesn't matter, you can just use a min or max aggregate query on AppPermissionID grouping by the Appraiser_fk.
Having said that, I question the logic of binding to the AppPermissionID when really the user is choosing an Appraiser_fk. If the user is choosing an Appraiser_fk, then the data should reflect that, not an arbitrary AppPermissionID.
Here is the thread that helped me come up with this solution: Many-to-Many-to-Many Relationship Problem. I see your point, though. I will see what I can come up with. I think that I might have an idea and it would solve this problem.
In this case, I don't think that it really matters which AppPermissionID I get since the filter is off and I can still get the appraiser that is tied to any of the AppPermissionIDs.
I will work on your solution to get the functionality out since it wouldn't cause a big design change, but I will also continue to work on getting the logic better.
Wow! That was so easy to fix the logic so that I'm not bound to the AppPermissionsID. I can't believe that I didn't come up with that sooner. Evidently I was looking for a hard solution, and I sure found it :)
Thanks Rabbit for inspiring me to fix the logic.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: BobG |
last post by:
-- The issue
This following query works fine on Toad and PowerBuilder yet when it is run
on SQLPlus I get: "ORA-03113: end-of-file on communication channel"
When I remove the distinct from the...
|
by: Perre Van Wilrijk |
last post by:
Hi,
I have a table as following
aa Text1 aa, p@xxx.be, 15267
aa Text1 aa, p@xxx.be, 16598
aa Text1 aa, p@xxx.be, 17568
aa Text2 aa, p@xxx.be, 25698
aa Text3 aa, x@zzz.be, 12258
|
by: mfyahya |
last post by:
I have two tables, both containing an 'authors' column. Is there a way
to get a unique list of authors from the two tables?
I tried SELECT DISTINCT `authors` from `table1`, `table2`;
but I got an...
|
by: Kelvin |
last post by:
Okay so this is baking my noodle. I want to select all the
attritbutes/fields from a table but then to excluded any row in which
a single attributes data has been duplicated.
I.E. Here's my...
|
by: John M |
last post by:
Hi,
The line below is used to feed a combobox. (It is from a database which is
used to log pupil behaviour!) The 'incidents' table contains a list of
students who have been involved in incidents....
|
by: mathilda |
last post by:
My boss has been adamant that SELECT DISTINCT is a faster query than
SELECT all other factors being equal. I disagree. We are linking an
Access front end to a SQL Server back end and normally are...
|
by: orekinbck |
last post by:
Hi There
Our test database has duplicate data:
COMPANYID COMPANYNAME
1 Grupple Group
2 Grupple Group
5 Grupple Group
3 Yada Inc
4 Yada...
|
by: Bob Stearns |
last post by:
I am getting duplicate rows back from a select distinct statement of the
form:
SELECT DISTINCT 'jhough', '000111', t0.bhid
FROM (SELECT lots of good stuff) t0
LEFT OUTER JOIN another_table ...
|
by: Genalube |
last post by:
I am running a query that includes the inclusion of memo fields, my query pulls from four different tables with one to many relationships between them. The relationships are such that when I run my...
|
by: bergy |
last post by:
Hello MS SQL experts, I'm trying to reorganize some data for a friend and I'm running into this problem. Currently he has some duplicate rows that I need to get rid of - only one of the columns has...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |