wiklendt
i recommend chocolate
- Local time
- Tomorrow, 00:47
- Joined
- Mar 10, 2008
- Messages
- 1,746
join properties or SQL view to return ALL jfields in crasstab query from BOTH tables?
hi, i have a crosstab query with two tables:
1) samples tested
2) targets to test against
i want to return ALL samples against ALL targets. at the moment, it seems the join properties in a query allows ONLY 3 ways to do it (i need "the 4th"!)
EITHER
all samples, but not all targets (does not return targets with no hits from a sample)
OR
all targets, but not all samples (does not return samples with no hits against a target)
OR
some of both, but not all of either (no negatives at all)
WHAT I WANT
is to return ALL samples with ALL targets (to return any targets that had no hits AND any samples that gave no hits) but in the one query, because i later am select-querying this crosstab, and would prefer not to have to make several to refer to. (indeed to review just on query to check the sample/target results would be a big help already)
my SQL for the three join types look like this, if it's any help to anyone:
(edit: in the following "qryRLBrun_results_forreport.Name" is the Sample, and "tblRLBtargets.ShortName" is the Target field - the other fields are extra info we thought would be handy in that cross tab, but i suppose can be added downstream if that helps my join issue)
"joined fields from both tables are equal"
"all records from target table"
"all records from sample table"
no one else seems to ever wanted to do this, unless i'm using the completely wrong keywords in my searches....
i've tried placing two instances of the target table in the query, and had jjoin properties set appropriately, but they cascade rather than for all records (i.e., targets > samples > targets does NOT return all targets for all samples for all targets)
and i have no idea how to manipulate this in SQL view... never worked with pivottables before (at least, the first time i realised i was using a pivot table each time i did a cross tab was when i just pasted that code in a second ago....)
anyone know how to overcome this issue?
(edit: snapshot of design view is attached, if that's any help to anyone)
(edit: i just noticed all the SQLs there have INNER, LEFT or RIGHT joins, i'm going to play around with changing them to OUTER joins, and see if that does anything.... seems hopeful.... wish me luck!)
hi, i have a crosstab query with two tables:
1) samples tested
2) targets to test against
i want to return ALL samples against ALL targets. at the moment, it seems the join properties in a query allows ONLY 3 ways to do it (i need "the 4th"!)
EITHER
all samples, but not all targets (does not return targets with no hits from a sample)
OR
all targets, but not all samples (does not return samples with no hits against a target)
OR
some of both, but not all of either (no negatives at all)
WHAT I WANT
is to return ALL samples with ALL targets (to return any targets that had no hits AND any samples that gave no hits) but in the one query, because i later am select-querying this crosstab, and would prefer not to have to make several to refer to. (indeed to review just on query to check the sample/target results would be a big help already)
my SQL for the three join types look like this, if it's any help to anyone:
(edit: in the following "qryRLBrun_results_forreport.Name" is the Sample, and "tblRLBtargets.ShortName" is the Target field - the other fields are extra info we thought would be handy in that cross tab, but i suppose can be added downstream if that helps my join issue)
"joined fields from both tables are equal"
Code:
TRANSFORM Count(qryRLBrun_results_forreport.RunDate) AS CountOfRunDate
SELECT qryRLBrun_results_forreport.Name, qryRLBrun_results_forreport.PlateAbbrev, Count(qryRLBrun_results_forreport.RunDate) AS [Total Of RunDate]
FROM tblRLBtargets INNER JOIN qryRLBrun_results_forreport ON tblRLBtargets.TargetID = qryRLBrun_results_forreport.RLB_Target
GROUP BY qryRLBrun_results_forreport.Name, qryRLBrun_results_forreport.PlateAbbrev
PIVOT tblRLBtargets.ShortName;
"all records from target table"
Code:
TRANSFORM Count(qryRLBrun_results_forreport.RunDate) AS CountOfRunDate
SELECT qryRLBrun_results_forreport.Name, qryRLBrun_results_forreport.PlateAbbrev, Count(qryRLBrun_results_forreport.RunDate) AS [Total Of RunDate]
FROM tblRLBtargets LEFT JOIN qryRLBrun_results_forreport ON tblRLBtargets.TargetID = qryRLBrun_results_forreport.RLB_Target
GROUP BY qryRLBrun_results_forreport.Name, qryRLBrun_results_forreport.PlateAbbrev
PIVOT tblRLBtargets.ShortName;
"all records from sample table"
Code:
TRANSFORM Count(qryRLBrun_results_forreport.RunDate) AS CountOfRunDate
SELECT qryRLBrun_results_forreport.Name, qryRLBrun_results_forreport.PlateAbbrev, Count(qryRLBrun_results_forreport.RunDate) AS [Total Of RunDate]
FROM tblRLBtargets RIGHT JOIN qryRLBrun_results_forreport ON tblRLBtargets.TargetID = qryRLBrun_results_forreport.RLB_Target
GROUP BY qryRLBrun_results_forreport.Name, qryRLBrun_results_forreport.PlateAbbrev
PIVOT tblRLBtargets.ShortName;
no one else seems to ever wanted to do this, unless i'm using the completely wrong keywords in my searches....
i've tried placing two instances of the target table in the query, and had jjoin properties set appropriately, but they cascade rather than for all records (i.e., targets > samples > targets does NOT return all targets for all samples for all targets)
and i have no idea how to manipulate this in SQL view... never worked with pivottables before (at least, the first time i realised i was using a pivot table each time i did a cross tab was when i just pasted that code in a second ago....)
anyone know how to overcome this issue?
(edit: snapshot of design view is attached, if that's any help to anyone)
(edit: i just noticed all the SQLs there have INNER, LEFT or RIGHT joins, i'm going to play around with changing them to OUTER joins, and see if that does anything.... seems hopeful.... wish me luck!)
Attachments
Last edited: