Rewriting a query and eliminating subqueries I have the following query : 

SELECT ws_id, n50, num_singletons, num_segments_less_100, kmer, num_all_reads, number_bases_in_contigs, 
 num_bases_in_singletons 
FROM stats_assembly WHERE ws_id IN (
  SELECT workflow_steps.id 
  FROM workflow_steps, workflows 
  WHERE workflow_steps.workflow_id = workflows.id 
      AND workflows.sample_id = (
            SELECT workflows.sample_id FROM workflows WHERE workflows.id = (
                SELECT workflow_id FROM workflow_steps WHERE id = 462
            )
            AND workflow_steps.submodule_id = 2
      )
)


And I want to rewrite it without using subqueries. So far I have been able to do only this: 

SELECT ws_id, n50, num_singletons, num_segments_less_100, kmer, num_all_reads, number_bases_in_contigs, 
  num_bases_in_singletons 
FROM stats_assembly 
INNER JOIN workflow_steps ON ( stats_assembly.ws_id = workflow_steps.id ) 
INNER JOIN workflows ON ( workflow_steps.workflow_id = workflows.id )


And I have no idea how to finish it. 

Furthermore, this query potentially returns multiple rows but I want to get the row which has MAX(ws_id). Any tips will be greatly appreciated.
I think this will get you there... cavaet: I'm a SQL Server person...

SELECT 
  ws_id
, n50
, num_singletons
, num_segments_less_100
, kmer
, num_all_reads
, number_bases_in_contigs
, num_bases_in_singletons 
FROM 
 stats_assembly sa
 join workflow_steps ws1 
   on sa.ws_id = ws1.id 
   and ws1.submodule_id = 2
 join workflows wf1 
   on ws1.workflow_id = wf1.id 
 join workflows wf2 
   on wf1.sample_id = wf2.sample_id 
 join workflow_steps ws2
   on wf2.id = ws2.workflow_id 
   and ws2.id = 462