select语句怎么写

1. select语句怎么写

关于select语句的书写,了解执行顺序很有必要,用下面的例子做介绍:

select语句怎么写

select from where group by having order by 中,

首先执行的是from后的语句,说明数据的来源;

-->执行where后的语句,对记录进行初步筛选;

-->执行group by后的语句,对初步筛选后剩下的字段进行分组;

-->执行having后的语句,对分组后的记录进行二次筛选;

-->执行select后的语句,在二次筛选后的字段中进行选择并显示出来;

-->执行order by后的语句,对select 后的字段进行排序。

2. 这个select 语句要怎么写

如果你想计算每日的订单总额应该是:

sql="select Date,sum(TotalPrice) as Total_Price from Statistics where Date between #" & FirstDate & "# And #" & EndDate & "# and Factory='"&Factory&"' group by Date order by Date desc"

如果你想要更多新信息:

sql="select Pono,Date,Style,Customer,Factory,sum(TotalPrice) as Total_Price from Statistics where Date between #" & FirstDate & "# And #" & EndDate & "# and Factory='"&Factory&"' group by Pono,Date,Style,Customer,Factory,id order by id desc"

select后非聚集运算Column必须出现在group by后。