我正在使用Postgres 9.4。我有以下查詢:Postgres:按LIKE表達式分組?
select sum(items) as items, sum(cost) as cost,
presentation_code, processing_date as date
from vw_presentation_summary
where presentation_code LIKE '011%' OR presentation_code LIKE '012%'
GROUP BY date, presentation_code;
這給我的結果是這樣的:
items | cost | presentation_code | date
-------+------------------+-------------------+------------
8243 | 273445.45 | 0212000AAAAACAC | 2014-03-01
366 | 10511.99 | 0212000AABBABAB | 2013-05-01
461 | 9232.04 | 0212000AABBADAD | 2014-02-01
但有什麼辦法可以組所有的結果011%
在一起,結果全部爲012%
在一起嗎?
我想我需要一個聚合函數?但不知道如何谷歌這... – Richard