1

早上好。我有这张桌子:

mysql> select * from Data;
+---------------------------+--------+-------+
| affyId                    | exptId | level |
+---------------------------+--------+-------+
| 31315_at                  | 3      |   250 |
| 31324_at                  | 3      |    91 |
| 31325_at                  | 1      |   191 |
| 31325_at                  | 2      |   101 |
| 31325_at                  | 4      |    51 |
| 31325_at                  | 5      |    71 |
| 31325_at                  | 6      |    31 |
| 31356_at                  | 3      |    91 |
| 31362_at                  | 3      |   260 |
| 31510_s_at                | 3      |   257 |
| 5321_at                   | 4      |    90 |
| 5322_at                   | 4      |    90 |
| 5323_at                   | 4      |    90 |
| 5324_at                   | 3      |    57 |
| 5324_at                   | 4      |    90 |
| 5325_at                   | 4      |    90 |
| AFFX-BioB-3_at            | 3      |    97 |
| AFFX-BioB-5_at            | 3      |    20 |
| AFFX-BioB-M_at            | 3      |    20 |
| AFFX-BioB-M_at            | 5      |   214 |
| AFFX-BioB-M_at            | 7      |    20 |
| AFFX-BioB-M_at            | 8      |    40 |
| AFFX-BioB-M_at            | 9      |    20 |
| AFFX-HSAC07/X00351_M_at   | 3      |    86 |
| AFFX-HUMBAPDH/M33197_3_st | 3      |   277 |
| AFFX-HUMTFFR/M11507_at    | 3      |    90 |
| AFFX-M27830_3_at          | 3      |   271 |
| AFFX-MurIL10_at           | 3      |     8 |
| AFFX-MurIL10_at           | 5      |     8 |
| AFFX-MurIL10_at           | 6      |     4 |
| AFFX-MurIL2_at            | 3      |    20 |
| AFFX-MurIL4_at            | 5      |    78 |
| AFFX-MurIL4_at            | 6      |    20 |
| U95-32123_at              | 1      |   128 |
| U95-32123_at              | 2      |   128 |
| U98-40474_at              | 1      |    57 |
| U98-40474_at              | 2      |    57 |
+---------------------------+--------+-------+
37 rows in set (0.00 sec)

如果我想在所有实验中寻找每个阵列探针 (affyId) 的平均表达水平 (level),我会SELECT affyId, AVG(level) AS average FROM Data GROUP BY affyId;

但是,我无法弄清楚如何查找每个实验的每个数组探针(affyId)的平均表达水平......它必须与上次查询类似,但我没有获得好的结果......有什么帮助吗?

PD:有人告诉我,如果有人解决了我的问题,我应该给予一些声誉或点击一些绿色按钮......对吗?我该怎么做?我是这个网站的新手...

4

2 回答 2

0

只需将其添加到group by子句中

SELECT affyId, exptId, AVG(level) AS average 
FROM Data
GROUP BY affyId, exptId;
于 2013-10-19T12:10:57.797 回答
0

这显示了每个 affyId 的平均值:

SELECT affyId, AVG(level) AS average FROM Data GROUP BY affyId

这是每个 exptId 的平均值:

SELECT exptId, AVG(level) AS average FROM Data GROUP BY exptId

这是每个 affyId 中每个 exptId 的平均值:

SELECT affyId, exptId, AVG(level) AS average FROM Data GROUP BY exptId, affyId
于 2013-10-19T12:11:41.103 回答