Postgresql查看聚合日期值

时间:2016-04-07 12:59:14

标签: postgresql join

A)我可以看到按参数分组的数据组列表:

 SELECT foo."ART_CODICE",
    foo."CLIENTE"
 FROM ( SELECT mytable."ART_CODICE",
            count(mytable."ART_CODICE") AS "QTA",
            mytable."CLIENTE"
        FROM mytable
        GROUP BY mytable."ART_CODICE") foo;

结果:

 ART_CODICE    CLIENTE   QTA    
 xxx           tizio     33    
 yyy           tizio     44

B)我可以看到这个月的小组列表:

 SELECT to_char(date_trunc('month', "DATA_PROD"),'YY-Mon') AS txn_month
    FROM "public"."mytable" "mytable"
 GROUP BY txn_month
 order by txn_month

有没有办法添加到A)B)的数据?

结果:

<table>
<th>ART_CODICE</th> <th> CLIENTE</th><th>   QTA</th>    <th>DATE</th>
<tr><td>xxx</td>           <td>tizio</td> <td>  33</td>     <td>15-Feb</td></tr>
</table>

0 个答案:

没有答案