2

いくつかの ingres データベースのものを継承しました。以前にイングレスを使用したことはありません。個別の電子メール アドレス レコードを分離する次のクエリを見つけました。

select a.reg_uid as id, a.firstname, a.lastname, a.postzip_code, a.suburb, a.city, a.state, a.email, a.country 
from register a
inner join 
(
 select distinct email, min(reg_uid) as id from register 
  group by email 
) as b
on a.email = b.email 
and a.id = b.id

ただし、これをイングレスにプラグインすると、エラーが発生します

"Table 'select' does not exist or is not owned by you."

何か案は?

4

2 に答える 2

1

Ingres 10S (10.1) を使用している場合は、次のように共通テーブル式 (CTE) を使用できます。

with b(email,id) as
(
 select distinct email, min(reg_uid) as id from register 
  group by email 
)
select a.reg_uid as id, a.firstname, a.lastname, a.postzip_code, a.suburb, a.city, a.state, a.email, a.country 
from register a
inner join b
on a.email = b.email 
and a.id = b.id

以前のバージョンでは、b のビューを作成するか (CTE は実際にはインライン ビューです)、次のように書き直すことができました。

select a.reg_uid as id, a.firstname, a.lastname, a.postzip_code, a.suburb, a.city, a.state, a.email, a.country 
from register a
where a.id = (
 select min(reg_uid) as id from register b
 where b.email=a.email
)
于 2013-10-23T11:04:40.623 に答える
0

Ingres 9であなたの正確なステートメントを正常に試しました:

create table register ( id char(10), reg_uid char(10), firstname char(10), lastname char(10), postzip_code char(10), suburb char(10), city char(10), state char(10), email char(10), country char(10) )

select a.reg_uid as id, a.firstname, a.lastname, a.postzip_code, a.suburb, a.city, a.state, a.email, a.country 
from register a
inner join 
(
 select distinct email, min(reg_uid) as id 
 from register 
  group by email 
) as b
on a.email = b.email 
and a.id = b.id
于 2014-08-19T13:23:47.980 に答える