0
我正在使用页面9.3,我想知道如何在一条语句中执行此操作,甚至可能没有临时表。这对我来说似乎有点混乱。Postgres语法内部连接更新和临时表
create temp table docUse (
docid int primary key,
name text, cnt int,
mindate timestamp,
maxdate timestamp);
insert into docuse (docid,cnt)
select documenttypeID, count(documenttypeID) from AllDocs group by documenttype;
update docuse set name = DocName from documenttype where documenttypeid = docid;
update docuse
set mindate = _minDate, maxdate = _MaxDate from(
Select min(Creation_Date) _mindate, max(Creation_Date) _MaxDate, docid did
from AllDocs inner join docuse on documenttypeid = docid group by docid
) foo where did = docid;
样本返回行看起来像
761,Invoice,598236,1/1/2000 12:00:00 am, 2/19/2016 3:15:54 pm