Open johanvonboer opened 5 months ago
This SQL returns only one analysis entity. Why should there be more?
select
tbl_sites.site_name as alias_1,
tbl_record_types.record_type_name as alias_2,
tbl_analysis_entities.analysis_entity_id as alias_3,
tbl_sites.site_id as alias_4,
tbl_sites.site_id as alias_5,
tbl_sites.site_name as alias_6,
facet.abundance_taxon_shortcut.taxon_name
from tbl_analysis_entities
inner join tbl_datasets on tbl_datasets."dataset_id" = tbl_analysis_entities."dataset_id"
inner join tbl_physical_samples on tbl_physical_samples."physical_sample_id" = tbl_analysis_entities."physical_sample_id"
inner join tbl_sample_groups on tbl_sample_groups."sample_group_id" = tbl_physical_samples."sample_group_id"
inner join tbl_sites on tbl_sites."site_id" = tbl_sample_groups."site_id"
inner join facet.abundance_taxon_shortcut on facet.abundance_taxon_shortcut."analysis_entity_id" = tbl_analysis_entities."analysis_entity_id"
left join tbl_methods on tbl_methods."method_id" = tbl_datasets."method_id"
left join tbl_record_types on tbl_record_types."record_type_id" = tbl_methods."record_type_id"
where 1 = 1
and (facet.abundance_taxon_shortcut.taxon_id::text in ('37303'))
and tbl_datasets.method_id in (3, 6)
and tbl_sites.site_id = 4602
Because it's impossible for a site which contains multiple datasets to only have 1 analysis_entity, and because of this sql:
SELECT * FROM tbl_sites
JOIN tbl_sample_groups ON tbl_sample_groups.site_id=tbl_sites.site_id
JOIN tbl_physical_samples ON tbl_physical_samples.sample_group_id=tbl_sample_groups.sample_group_id
JOIN tbl_analysis_entities ON tbl_analysis_entities.physical_sample_id=tbl_physical_samples.physical_sample_id
WHERE tbl_sites.site_id=4602
But your example has a filter on taxon_id 37303?
This example shows Reykholt having 1 analysis_entity:
But it has many more.
This is the SQL returned from the server: