0

表 PROBE 如下所示:

'ProbeID'----- 'TranscriptID' ---- 'Start'---- 'End'

'1056'-----------'7981326'----------'1013'---'1010'

'1057'-----------'7878826'----------'1011'---'1015'

etc..

表 EXPRESSION2 如下所示:

'ProbeID'----- 'SampleID' ---- 'Value'

'10425'---------'7981326'-----'16.55''

'11123'---------'7878826'----- '3.55'

etc..

我需要找到成绩单中最大的 100 个差异(即取探针的平均值)。

本质上,我需要将 EXPRESSION2 表的 ProbeID 与 PROBE 表中的 TranscriptID 链接起来,并计算前 100 名的平均值。

我尝试了下面的代码,但不断收到“null”返回。任何替代脚本将不胜感激。我想我错过了一些东西。

EXPRESSION2 表没有空值,仅供参考

`选择平均值(值)

从表达式2

    where probeID in  
                    (   
                      select P.ProbeId 
                           from Probe P
                            join Transcript T on P.TranscriptID = T.TranscriptID

)`

限制100;`

4

2 回答 2

0

If you whant to eliminate the null values

select e.probeID, avg(value) as avarage
from expression2 e
    inner join 
    (
        select P.ProbeId 
        from Probe P 
            join Transcript T on P.TranscriptID = T.TranscriptID    
    ) p on e.probeID = p.probeID
where e.value is not null
group by e.probeID

if you whant to treat them as 0

select e.probeID, avg(COALESCE(value,0)) as avarage
from expression2 e
    inner join 
    (
        select P.ProbeId 
        from Probe P 
            join Transcript T on P.TranscriptID = T.TranscriptID    
    ) p on e.probeID = p.probeID
group by e.probeID
于 2012-10-30T00:08:17.070 回答
0

Which DBMS are you using? Is it significant that there are no matching ProbeIDs in the two tables in your example, but there are matching TranscriptID/SampleID pairs?

Select Top 100
  p.TranscriptID,
  Avg(e.Value)
From
  Probe p
    Inner Join
  Expression2 e
     on p.ProbeID = e.ProbeID
Group By
  p.TranscriptID
Order By
  2 Desc
于 2012-10-30T00:10:17.730 回答