1

だから私はこれは本当に醜い(しかし機能的な)複数のサブクエリmysqlSelectコマンドを持っています。

select myt_taxon_list, count(myt_taxon_list)
from (select t1.taxon_list as myt_taxon_list, t1.query_prot_id,
             count(t1.query_prot_id) / (select count(t.id)
                                        from taxa t, stax st
                                        where t.systematics like concat('%; ', st.taxon_list, '%')
                                              and t.taxon_name not like '%thaliana%'
                                              and st.taxon_list = t1.taxon_list
                                        group by t1.taxon_list) as taxfrac
      from task1 t1
      where t1.taxon_list = 'Stramenopiles'
      group by t1.query_prot_id) myt 
where taxfrac > 0.5

最後の行で「Stramenopiles」を読むことができます。この結果は単純なカウントです。ここで、ストラメノパイルだけでなく、その列のすべてのエントリのカウントを、合計としてではなく、分離されたすべてのエントリのカウントを書き込むbashスクリプトを作成します。これをbashの反復ループと組み合わせる必要がありますが、これまでスクリプトを作成したことはありません。誰かがこれを手伝ってくれますか?

4

1 に答える 1

1

私はこれをbashではまったくしません。外すと

where t1.taxon_list = 'Stramenopiles'

group by myt_taxon_list外側の選択でa を使用できます

select myt_taxon_list, count(myt_taxon_list)
from (select t1.taxon_list as myt_taxon_list, t1.query_prot_id,
             count(t1.query_prot_id) / (select count(t.id)
                                        from taxa t, stax st
                                        where t.systematics like concat('%; ', st.taxon_list, '%')
                                              and t.taxon_name not like '%thaliana%'
                                              and st.taxon_list = t1.taxon_list
                                        group by t1.taxon_list) as taxfrac
      from task1 t1
      group by t1.query_prot_id, t1.taxon_list) myt 
where taxfrac > 0.5
group by myt_taxon_list

これにより、すべてのtaxon_listエントリが適切にカウントされます。

于 2013-03-01T14:20:19.227 に答える