I would like to display the count of each “aa_change” in each “tumor_type” in one field and the count of distinct “samples_ids” in each “tumor_type” in another field on a continuous form.
Instead of a summary table I would like incorporate these statistics with each record in “Variant” table. The form will display each record from "tblVariant" and also one column for count of “aa_change” in each "tumor type" and a column with the count of distinct “sample_ids” in each “tumor_type”.
Please see the screenshot of the table structure. I’ve managed to come up with three separate queries that return the correct information but I’m not sure how to combine them into one, if possible. This seems very complicated.
Query1: Count of each aa_change in tumor_type
SELECT tbl_Samples.tumor_type, Count(tbl_Variants.aa_change) AS exp, tbl_Variants.aa_change
FROM tbl_Samples INNER JOIN tbl_Variants ON tbl_Samples.sample_id = tbl_Variants.sample_id
GROUP BY tbl_Samples.tumor_type, tbl_Variants.aa_change;
Query2: Count of distinct sample ids for each tumor_type.
SELECT tbl_Samples.tumor_type, Count(tbl_Samples.[sample_id]) AS exp
FROM tbl_Samples
GROUP BY tbl_Samples.tumor_type;
Query3: all fields from tblVariants.
Thanks for your help, Mila
Instead of a summary table I would like incorporate these statistics with each record in “Variant” table. The form will display each record from "tblVariant" and also one column for count of “aa_change” in each "tumor type" and a column with the count of distinct “sample_ids” in each “tumor_type”.
Please see the screenshot of the table structure. I’ve managed to come up with three separate queries that return the correct information but I’m not sure how to combine them into one, if possible. This seems very complicated.
Query1: Count of each aa_change in tumor_type
SELECT tbl_Samples.tumor_type, Count(tbl_Variants.aa_change) AS exp, tbl_Variants.aa_change
FROM tbl_Samples INNER JOIN tbl_Variants ON tbl_Samples.sample_id = tbl_Variants.sample_id
GROUP BY tbl_Samples.tumor_type, tbl_Variants.aa_change;
Query2: Count of distinct sample ids for each tumor_type.
SELECT tbl_Samples.tumor_type, Count(tbl_Samples.[sample_id]) AS exp
FROM tbl_Samples
GROUP BY tbl_Samples.tumor_type;
Query3: all fields from tblVariants.
Thanks for your help, Mila