从视图中计算不同的记录

时间:2014-01-24 14:49:52

标签: mysql sql

我想我知道如何计算表格中的不同记录:

SELECT COUNT(DISTINCT device_guid) 
FROM 002_device_guid_group_and_device_data;

但是002_device_guid_group_and_device_data是一个不是表的视图而且正在返回:

ERROR 1146 (42S02): Table 'nimevents.002_device_guid_group_and_device_data' doesn't exist

针对视图运行是否有不同的语法?

以下评论

视图必须存在:

DESCRIBE 002_guid_group_and_device_data;
+-----------------+--------------+------+-----+---------+-------+
| Field           | Type         | Null | Key | Default | Extra |
+-----------------+--------------+------+-----+---------+-------+
| device_guid     | char(37)     | YES  |     | NULL    |       |
| etl_create_date | datetime     | YES  |     | NULL    |       |
| dwell_minutes   | int(11)      | YES  |     | NULL    |       |
| device_brand    | varchar(128) | YES  |     | NULL    |       |
| device_product  | varchar(128) | YES  |     | NULL    |       |
| device_os       | varchar(128) | YES  |     | NULL    |       |
+-----------------+--------------+------+-----+---------+-------+

0 个答案:

没有答案