Which assets have 2 parts? Show me its id and details.
select t1.asset_id, t1.asset_details from assets as t1 join asset_parts as t2 on t1.asset_id = t2.asset_id group by t1.asset_id having count(*) = 2
Which assets have less than 2 fault logs? Show me its id and details.
select t1.asset_id, t1.asset_details from assets as t1 join fault_log as t2 on t1.asset_id = t2.asset_id group by t1.asset_id having count(*) < 2
Which assets fulfill both of those conditions? Show me asset id and details.
select t1.asset_id, t1.asset_details from assets as t1 join asset_parts as t2 on t1.asset_id = t2.asset_id group by t1.asset_id having count(*) = 2 intersect select t1.asset_id, t1.asset_details from assets as t1 join fault_log as t2 on t1.asset_id = t2.asset_id group by t1.asset_id having count(*) < 2