mysql に「変換」しようとしているクエリがあります。クエリは次のとおりです。
select top 5 *
from
(select id, firstName, lastName, sum(fileSize) as TotalBytes, sum(fileSize)/count(b.*) as Average
from roster_cs368 a
join htmp_cs3868 b on b.id = a.id
)
union
(
select id, firstName, lastName, sum(fileSize) as TotalBytes, sum(fileSize)/count(b.*) as Average
from roster_cs368 a
join atmp_cs3868 b on b.id = a.id
)
order by TotalBytes desc
誰かが「mysql: やり方」を教えてくれることを期待しています。本当に感謝しています。これは私が行っている Java プログラムの一部であり、まだ SQL クエリにあまり慣れていません。
アップデート:
mysql> select * from roster_cs368
-> ;
+--------+-----------+-----------+
| id | firstName | lastName |
+--------+-----------+-----------+
| apn7cf | Allen | Newton |
| atggg3 | andrew | goebel |
| aysfgd | Alfred | Santos |
| cdq6c | chris | declama |
ここで、「id」は主キーです
mysql> select * from htmp_cs368;
+------------+----------+------------+----------+----------+-------+------+-------+----------------------+
| filePerms | numLinks | id | idGroup | fileSize | month | day | time | fileName |
+------------+----------+------------+----------+----------+-------+------+-------+----------------------+
| drwx------ | 2 | schulte | faculty | 289 | Nov | 7 | 2011 | Java |
| -rw-r--r-- | 1 | schulte | faculty | 136 | Apr | 29 | 2012 | LD |
| drwxr-xr-x | 3 | schulte | faculty | 177 | Mar | 20 | 2012 | Upgrade |
ここには主キーはなく、最後のテーブル:
mysql> select * from atmp_cs368;
+------------+----------+--------------+----------+----------+-------+------+-------+-----------------------------+
| filePerms | numLinks | id | idGroup | fileSize | month | day | time | fileName |
+------------+----------+--------------+----------+----------+-------+------+-------+-----------------------------+
| drwxr-xr-x | 2 | remierm | 203 | 245 | Sep | 17 | 14:40 | 148360_sun_studio_12 |
| drwx---rwx | 31 | antognolij | sasl | 2315 | Oct | 24 | 12:28 | 275 |
| -rwx------ | 1 | kyzvdb | student | 36 | Sep | 19 | 13:05 | 275hh |
| drwx---rwx | 26 | antognolij | sasl | 1683 | Nov | 12 | 14:00 | 401 |
ここにも主キーはありません。
私が答える質問は次のとおりです。
produce a list of the five members of roster_cs368
and their ids who use the most space (number of bytes)
in htmp_cs368 and atmp_cs368 in descending order--
greediest first.
この情報が役立つことを願っています。提示された表には、さらに多くの情報が含まれていることに注意してください。ここにあるのはほんの一部です。