mysql显示每个关税名称的列

时间:2014-07-05 21:25:18

标签: mysql

我有下表

+------------+------------------------+-------------+-------------+--------+
| dialprefix | destination            | rateinitial | tariffname  | id     |
+------------+------------------------+-------------+-------------+--------+
| 1          | North American Region  |     0.01710 | Call Center | 476610 |
| 1201       | United States          |     0.01710 | Call Center | 512642 |
| 1201       | United States          |     0.01110 | Direct      | 586007 |
| 1201       | United States          |     0.01055 | Standard    | 622786 |
| 1201       | United States          |     0.02949 | Premium     | 549254 |
| 1201763    | United States - OffNet |     0.01785 | Call Center | 499834 |
| 12017632   | United States - OffNet |     0.01785 | Call Center | 510969 |
| 12017636   | United States - OffNet |     0.01785 | Call Center | 510970 |
| 12017637   | United States - OffNet |     0.01785 | Call Center | 510971 |
| 12017638   | United States - OffNet |     0.01785 | Call Center | 510972 |
+------------+------------------------+-------------+-------------+--------+
在“关税名称”列中的

显示不同的名称,如:呼叫中心,直接,高级,标准。

我需要显示什么mysql查询,以显示每个关税名称的列并包括费率,还删除任何dialprefix重复项,并仅使用一个来显示其费率。例如:

+------------+------------------------+-------------+-------------+-------------+-------------+
| dialprefix | destination            | Call Center | Standard    | premium     | Direct      |
+------------+------------------------+-------------+-------------+-------------+-------------+
| 1201       | United States          | 0.01710     | 0.01055     | 0.02949     | 0.01110     |
+------------+------------------------+-------------+-------------+-------------+-------------+

此查询稍后将进行json编码并传递给数据表以显示数据。

这是我现在使用的查询:

select cc_ratecard.dialprefix, cc_prefix.destination , cc_ratecard.rateinitial, cc_tariffplan.tariffname, cc_ratecard.id
from cc_ratecard, cc_prefix, cc_tariffplan
where cc_ratecard.dialprefix = cc_prefix.prefix
and cc_tariffplan.id = cc_ratecard.idtariffplan

0 个答案:

没有答案