## 请问这种语句，如何创建索引呢？

```EXPLAIN    SELECT
a.title   AS game_title,
b.game_id,
SUM(b.total_rmb) AS all_rmb
FROM game a
JOIN hive_3orders_stat b
ON a.id = b.game_id
WHERE b.date BETWEEN '2012-05-01'
AND '2012-05-31'
GROUP BY b.game_id

ORDER BY all_rmb DESC```

0
b.date 字段也要做索引哦
date做了索引的，我发的第一张图片是hive_3orders_stat的索引
0
l
```SELECT a.title AS game_title,a.id,
(SUM(b.total_rmb) FROM hive_3orders_stat b WHERE a.id=b.game_id AND date BETWEEN '2012-05-01' AND '2012-05-31') AS all_rmb
FROM game a
GROUP BY a.id
ORDER BY all_rmb DESC```

l

0

#### 引用来自“lhohoz”的答案

```SELECT a.title AS game_title,a.id,
(SUM(b.total_rmb) FROM hive_3orders_stat b WHERE a.id=b.game_id AND date BETWEEN '2012-05-01' AND '2012-05-31') AS all_rmb
FROM game a
GROUP BY a.id
ORDER BY all_rmb DESC```

0

l

l

0
```EXPLAIN    SELECT
a.title   AS game_title,
a.id AS game_id,
SUM(b.total_rmb) AS all_rmb
FROM game a
, hive_3orders_stat b

WHERE (b.date BETWEEN '2012-05-01'
AND '2012-05-31') AND a.id = b.game_id
GROUP BY a.id

ORDER BY all_rmb DESC```