0

我有两张桌子。一个是“探针”,另一个是“成绩单”。

探针表:“探针”

ProbeID-------TranscriptID----

2655       4555555
2600       5454542
2600       4543234
2344       5659595

...ETC

成绩单表:“成绩单”

成绩单ID----位置----

7896736      chr1
5454542      chr1

...ETC

我需要找出每条染色体有多少转录本?和 每条染色体有多少个探针?

SELECT COUNT(*) 
FROM transcript

= '28869' #以上我认为给了我每条染色体的转录本(即位置)。

我需要帮助回答第二部分(首先,如果它错了)。我假设我需要使用该JOIN子句。

谢谢你。

4

2 回答 2

0

每个染色体的探针数

SELECT Location, COUNT(ProbeID) AS ProbeCnt
FROM transcript T
JOIN probe P ON P.TransciprtID = T.TranscriptID
GROUP BY Location
-- optionally you can ORDER BY to either get
-- ORDER BY COUNT(ProbID) DESC  --  list in descending order of nb of probes
-- ORDER BY Location            --  list in order of chromosome name

至于您的第一个查询,它是不正确的。要获得
每条染色体的转录本数,您需要

SELECT Location, COUNT(TranscriptID) as TransCnt
FROM transcript
GROUP BY Location

您当前的查询给出了整个成绩单表的成绩单总数,而不考虑染色体。

于 2012-10-24T03:14:57.650 回答
0

成绩单计数

select location, count(location) AS transacripts_num 
from transcript GROUP by location;

探针计数

select location, count(location) AS probe_num 
from transcript t join probe p
ON t.transcriptId= p.probeId
GROUP by location;
于 2012-10-24T03:18:31.610 回答