Counting Joined Tuples
Sep 6, 2006Hi,
I have two tables A and B that I joined using a LEFT JOIN. I know that some rows in table B will not be joined. How do I count how many will not be joined and how do I return those rows?
Thanks
ClaudiaM
Hi,
I have two tables A and B that I joined using a LEFT JOIN. I know that some rows in table B will not be joined. How do I count how many will not be joined and how do I return those rows?
Thanks
ClaudiaM
Col1 Col2
A 10 10
B 15 15
C 20 12
D 25 9
E 30 20
F 35 18
G 40 2
H 50 23
I 55 1
J 60 18
I have to get the Top 5 for each Col, grouped by group, but all in one table. What I did was split Col1 to one query with a return of 5. And also did that with Col2. But now I have to join them, and only a few records pop up, those which have the same group name, all others were excluded...what can I do?
Hi...
I have an Access query, which gives me the "orphans", between two tables.
They look like this
tblSurveys tblJobs
* *
Grade -> JobGrade
Paytype -> JobPayType
Survey -> JobSurvey
other... -> other (including jobcode)
Linked as indicated, (all from tblSurvey to those matching tblJobs)
with criteria, WHERE jobcode is null
Ie. an unmatched query between tblSurvey and tblJobs.
Now I want to delete those from the survey where there is no jobs.
But when I change my select query to a delete query, I get the error:
Cannot delete from specified tables
My SQL (access generated) looks like this:
DELETE tblSurveys.*, tblJobs.JobCode
FROM tblSurvey LEFT JOIN tblJobs ON
(tblSurveys.Grade = tblJobs.JobGrade) AND
(tblSurveys.PayType = tblJobs.JobPayType) AND
(tblSurveys.Survey = tblJobs.JobSurvey)
WHERE (((tblJobs.JobCode) Is Null));
That first line looks wrong...
Anyway, if someone can help me to delete these I will be forever grateful.
The way I understand it, a delete query should look more simple... ie
delete * from tblName where (and type the intricate stuff here)
Thanks in advance
Reenen
(BTW: I posted this on Ozgrid as well, but they are bigger on Excel there, and response times are better here. Apologies in advance)
If I use order by on a query that has two linked tables I keep getting an error:
This is the query
SELECT d.PDetailsID, d.po_id, d.po_uniqid, d.job_id,
d.p_qnty, d.p_desc, d.p_unitp, d.p_units,
d.p_extend, d.p_qos, d.p_grec, d.p_done,
d.cocreq, d.est_id, d.line, d.class,
d.selected, d.itemid, d.category, d.GroupID,
d.p_qosextended, d.late, d.lastsavedby, d.matid,
d.customer, SQLACCESS.tblctpur_d.jobid, d.DTime, d.Notes,
d.DescDetails, h.pur_ddue
FROM SQLACCESS.tblctpur_h as h INNER JOIN
SQLACCESS.tblctpur_d as d ON h.pur_id = d.po_id
ORDER BY d.line
The error is :
The colum prefix d does not match with a table or alias used in the query
What I'm trying to accomplish is probably really simple that I just can't get it to work. I have set up the relationship properly, I think. Here is what it looks like:
tblProjects(ProjectID[PK],ProjectName, ProjectType, ProjectDate)
tblMembers(MemberID[PK], MemberName)
tblRoles(RoleID[PK], RoleName)
tblProjMemb(ProjMembID[PK], ProjectID[FK], MemberID[FK], RoleID[FK])
Each project will have three different member roles. Here is what I'm trying to get from my db:
myQuery(tblProjects.*, tblMembers.MemberID As Role1ID, tblMembers.MemberName As Role1, tblMembers.MemberID As Role2ID, tblMembers.MemberName As Role2, tblMembers.MemberID As Role3ID, tblMembers.MemberName As Role3)
I need Role1ID = Role1 If when tblProjMemb.RoleID = 1. I need to create a column for each of the three member roles and have the name of that person in that column.
I'm not sure how to accomplish this. Any help is much appreciated. Thanks!
I have two tables in my database
Agents
Zip Codes (linked table)
If I create a query and then a form off the query that includes fields from both tables - Access will not let me add new records.
Ultimatley what I am looking to do is have a zip code field in the Agents table that I fill in and then it will automatically look at the zip codes table and then fill in the zip code, county, & state in a different area of the form.
I tried using fields from both tables and tried a query using fields from both tables and it will not let me add new records.
I have a relationship between the fields in both tables.
What am I doing wrong. I know this can be done.
Any help would be great!!!
Hi,
I have problem with pdf-ing a report that has record source coming from a query namely from the two tables joined based on the same of several fields (foreign keys).
I have PDF coding that would turn Access report to PDF report. It has no problem when the report's record source is from one table only.
Just wonder if anyone who might have a similar issue would like to share with me some help. Is it normal that PDF doesn't work if the report comes from joined tables in Access?
Thank you in advance
I am using the following query to identify rows in one table that have no match in another:
SELECT MAS.MASID
FROM MAS LEFT JOIN IVT ON MAS.Field1=IVT.Field1
WHERE ((IVT.IVTID) Is Null);
MAS is one file with MASID as the key.
IVT is the other file with IVTID as the key
This provides me a list of the rows in MAS with no match in IVT.
I now want to delete these rows in MAS so we can process the other fields in the table.
what is the syntax for the delete statement? I can't get the join to fit in correctly.
Help!
I have created a query that show all the records form Material Estimation table that the job number matches in the Production Table, that the AssDate is between the frm_Export_Data dates.
This the SQL view of the query.
DELETE [Material Estimation].*, Production.[AssDate]
FROM [Material Estimation] INNER JOIN Production ON [Material Estimation].[Job Number] = Production.[Job #]
WHERE (((Production.[AssDate]) Between [Forms]![frm_Export_Data]![FromDate] And [Forms]![frm_Export_Data]![ToDate]));
I want to delete all the records in the Material Estimation table that show up in this query.
Is this possible?
Thank you...
Hi,
I am getting information on products stored in a query. I want that query to check a couple tables to see if an item is linked through all of them. If it is not listed in the last table (catalog) I want it to be shown.
Code:Catalog tableVolume Prefixprodno Price15 - CE 0218 9.9915 - CE 0722 3.7215 - CF 0218 12.3615 - CF 0091 14.00Source TableSource MediaCM70904 15 - CE
Code:Batches QueryCustomer Number Prefixprodno Source716933 0218 CM70904716933 0408 CM70904
This is the Select Statement I'm using, which gets the 0218 but not the 0408 I want
Code:SELECT (fieldnames......)FROM [Batches] INNER JOIN ([Source] INNER JOIN [Catalog] ON [Source].[Media] = [Catalog].Volume) ON ([Batches].Source = [Source].[Source]) AND ([Batches].Prefixprodno IN ([Catalog].Prefixprodno))WHERE [Batches].[Customer Number]=716933;
If I do NOT IN I get both 0218 and 0408. I just want 0408. I'm sorry if this seems confusing but any help would be amazing at this point =/
I can not, or not allowed to enter data in fields in a query built from three tables that are jointed by a common field with the same name. The parent table is linked to another Access data base as is one child table the other is local data. Also, I am not able to view the child table data when viewing the parent table.
View 1 Replies View Relatedhi
I have a query I'm creating that is using a joined view. I'm joining two tables and whereas the first contains unique data to each field the second contans class information so for example while all users are unique many may be assigned to the same class. When i use the join it therefore dupliactes all the class information in the query.
how can i set up the query so that the class information is only output once and not duplicated along with a user every time ?
cheers
chris
I a report based on query based on joined tables. Im using FK and PK accordingly in the tables and have a junction table.
I've attached a sample (removed all unique identifiers for privacy in case you're wondering).
Table structure as follows:
Employees tbl - Junction (License Link tbl) License No tbl, License Class tbl, Endorsements tbl
So the query runs on all of these tables.
When I build a report on the query, Simon shows up Six times. I suspect because he has six endorsements.
How do I produce a report on this table/query structure so that I get:
Simon.
Class, 1,2,3,4,5
Endorsement F,R,T,W,DG
I have at least 3 relates tables in my access database.the first(sessions) table stores session detailes like id,date,time
The second one (tblemployees) contains our employees details like name, idp ,the third (attreq) relates the first table to second it stores ids of sessions and ids of personals that which determine which personals have attended in special sessions.
Now,my problem is that I want when a personnel log in and opens "confirmed session"form ,the access check and open records that this person have attended. How can I do it?
I have a report due the first of each week in which I need the cases open and cases closed for the previous week, the week two weeks prior and the 2007 and 2006 year to date on two different types of cases. I have a case management table with a field for Type of Case, date assigned and date closed that I uses in my queries. Presently I have two query, one that generates only Type 1 cases from the Case Management Table and another for Type 2. I then use the Type 1 Query in another query that limits the results for Type 1 cases to those opened last week, one for those open two weeks ago, one for 2006 YTD and one for 2007 YTD. In these 4 queries I have one field [Type of Cases] and I have the query count. I then do this for Type 2 cases and then go through the whole process to do Closed Cases. All my queries have criteria to automatically filter the dates to the time periods mentioned above. I then have one report query that I put all the number in for my report. This query has 16 fields with the numbers for each period, last week open and closed, 2 weeks open and closed, etc. I then generated a report that takes these numbers from my report query and puts it in a report format automatically. As you can imagine this takes some time to go through each query to generate these numbers, so I was wondering how I may do this differently. Also, I have experienced a problem when a field produces no records I get a blank sceen with nothing under the Count of column and get the same thing for my report. How can I fix this.
View 1 Replies View RelatedHello all,
I have made a crosstab query that is sporatically making duplicate counts. I'd like to know how to fix the problem, but more importantly - I'd like to know why and how my query is giving me these results so I can avoid making this same mistake again.
The relationship is set up so that all records from one table are returned, with only matching records from the other - so no problems that way as far as I can see. This is my crosstab query that is giving some counts of the same record as being matched sometimes two, three, or even four times:
TRANSFORM
Count([Testing DB].[DB_ID]) AS [CountOfDB_ID]
SELECT
[Testing DB].State, [Location].[North], Count([Testing DB].[DB_ID])
AS [Total Of DB_ID]
FROM [Testing DB] LEFT JOIN [Location] ON [Testing DB].[Address] = [Location].Address
WHERE (([Testing DB].[Window Length]) Is Not Null))
GROUP BY [Testing DB].State, [Location].[Size]
ORDER BY [Testing DB].State, [Location].[Size]
PIVOT Format([Date],"mmm-yyyy");
When I do a simple query for a list of the records being counted by this query, I can see the duplicate entries and can eliminate them simply by adding "Distinct" to the select statement - but I haven't had any luck adding any kind of distinction with this crosstab that will do the same.
How can I eliminate duplicate counts of records in my crosstab? If anyone has a suggestion, it would be much appreciated.
I have a client database that has recently had multiple duplicate entries. I need to reduce or negate this erroneous activity. I have a client table where I record amongst others, the following;
key
[christian_name]
[family_name]
[dob]
......
I believe that to prevent duplicate entrie via form I have created an additional field called "unique" given it as a unique index which I want to have populated with the joined fields first_name & last_name & dob (IE johndoe01/01/90), and then as user enters a new client it wont allow a duplicate.
However I need to fill all the existing customers (3600+) with the relevant joined existing data. If I create an expression I can cajoin the fields in a select query but when I try to make an update query the same syntax comes up with empty fields.
select query sql that worked to show field ...
SELECT divers.christian_name, divers.family_name, divers.dob, [christian_name] & [family_name] & [dob] AS Expr1
FROM divers;
update query that was empty ..
UPDATE divers SET divers.[unique] = [christian_name] & [family_name] & [dob];
I have a query, that I have a criteria to show appointments in the past (< Date()) but one result doesn't show up although the appointment end date is a past date, it only shows up when I fill in a field that is in another table that is joined and part of the query. But there's no criteria there for it to not be null.
View 3 Replies View RelatedI have a Table with 6 fields, 2 are named Initial and Surname. Is it at all possible to have a combo box on a form with these to fields "joined" with the alphabetical order on the Surname. I understand that using a query will not work as the result is based on an expression
View 11 Replies View RelatedI have an Access Table with about 28,000 Automobile dealerships across the country shown. I've joined a new/small phone contact table to this to keep up with our phone contacts with the dealership and followup efforts. When I search/filter on the dealership table all is fine. However when I search/filter on the phone contact table with a few test entries, I get nothing at all. I supposed that after joining the tables, I'd be able to do a search on the field named follow up date and find/filter today's date or other dates and locate which dealerships to contact when the correct date arrives. But nothing.
View 14 Replies View Relatedi am trying to count the number of records based in a query
can some one send me in the right direction
I have a database where there are numerous fields but they all only have one three values Y, N, N/A.
how do i get something similar to Excels "countif" function to summarise the totals of Y's N's N/A's inach field ?
Thanks
I have a database where there are numerous fields but they all only have one three values Y, N, N/A.
how do i get something similar to Excels "countif" function to summarise the totals of Y's N's N/A's in each field ?
Thanks
How can I count the number of times an employee shows up on a report. The final result would be:
Employee 1: Reader1
Employee 1: Reader2
Employee 1: Reader3
Employee 1: Reader4
If an employee shows on a report 4 times, I need it to look like the example above in sequential order, not just a total.
Thanks for your help.
Hi
I have a form which displays which products are on sale but I want it to count stcok orders down, i.e. if there are 10 stock and someone orders 1 I want the system to automatically recognise that there are only now 9 in stock, any ideas? Help really would be appreciated!
Thanks
B
Hello,
I have a form called feedback which has three columns and each cell in a column has a combo box that holds (Yes/No/Empty), and I want to count each column's value for example let's supposed that:
feeback number: Column 1 (Are You happy) - Column 2 (Are you sad) - Column 3 (Are you hungry)
1 : Yes - No - Yes
2 : Yes - Yes - Yes
3 : No - No - Yes
4 : empty - No - yes
Counting: the next step is that I want to count:
values in Column 1, where number of Yes =2 , and number of No=1 the stum of Yes + No = 3 and empty = 1
values in Column 2, where number of Yes =1 , and number of No=3 the stum of Yes + No = 4 and empty = 0
values in Column 3, where number of Yes =4 , and number of No=0 the stum of Yes + No = 4 and empty = 0
So, how can I apply this concept in MS ACCESS (2000-2003).
I am waiting for you kindly reply.