1. --复杂查询示例一
2. SELECT attr3,
3. COUNT(attr3) AS user_order_count
4. FROM <tableName>
5. GROUP BY attr3
6. HAVING user_order_count > 100
7.
8. --复杂查询示例二
9. SELECT *
10. FROM order_table
11. ORDER BY order_time DESC limit 10
12.
13. --复杂查询示例三
14. SELECT *
15. FROM order_table
16. WHERE order_time =
17. (SELECT max(order_time)
18. FROM order_table )
19.
20. --复杂查询示例四
21. SELECT attr3,
22. COUNT(attr3) AS user_order_count
23. FROM order_table
24. WHERE attr3 IN
25. (SELECT attr3
26. FROM order_table
27. WHERE order_position within st_makeMBR(116, 39, 116.5, 39.5)
28. AND order_time
29. BETWEEN '2018-10-01 00:00:00'
30. AND '2018-11-01 00:00:00' )
31. GROUP BY attr3
32. HAVING user_order_count > 100
33.
34. --复杂查询示例五
35. SELECT *
36. FROM order_table
37. WHERE order_time IN
38. (SELECT DISTINCT order_time
39. FROM order_table
40. ORDER BY order_time DESC limit 10 )
41.
42. --复杂查询示例第六个
43. SELECT s_fixed.attr3,
44. order_count_fixed_spatio,
45. order_count_fixed_temporal
46. FROM
47. (SELECT attr3,
48. COUNT(attr3) AS order_count_fixed_spatio
49. FROM order_table
50. WHERE order_position within st_makeMBR(116, 39, 116.5, 39.5)
51. GROUP BY attr3
52. HAVING order_count_fixed_spatio > 5 ) AS s_fixed
53. JOIN
54. (SELECT attr3,
55. COUNT(attr3) AS order_count_fixed_temporal
56. FROM order_table
57. WHERE order_time
58. BETWEEN '2018-10-01 00:00:00'
59. AND '2018-11-01 00:00:00'
60. GROUP BY attr3
61. HAVING order_count_fixed_temporal > 5 ) AS t_fixed
62. ON s_fixed.attr3 = t_fixed.attr3