sqlite查询简单选择查询

时间:2014-09-21 08:36:52

标签: sql sqlite

我是sqlite查询的新手。任何人都可以告诉我如何通过选择设置一些特定的行?

MY_TABLE

+------------+--------------+----------+
| client_id  | product_type |   value  |
+============+==============+==========+
|    2       |     2        | Server   |    
|    2       |     4        | Domain   | 
|    2       |     2        | Hosting  |     
|    3       |     2        | Dialer   |    
|    2       |     3        | Drive    |
+------------+--------------+----------+  

我如何才能获得client_idproduct_type,只有下面的行集 -

+-------------+---------------+
| client_id   | product_type  |
+=============+===============+
|    2        |     3         |   
|    3        |     2         |
+-------------+---------------+

2 个答案:

答案 0 :(得分:0)

<强> QUERY

sqlite> SELECT client_id,product_type
...> FROM client
...> GROUP BY client_id;

CHECK THIS DEMO


enter image description here

答案 1 :(得分:-2)

SELECT sensor_id,event_type FROM events group by sensor_id ORDER BY sensor_id ASC;