English 中文(简体)
用2个数字表示
原标题:Use two DISTINCT statements in SQL

I have combined two different tables together, one side is named DynDom and the other is CATH. I am trying to remove duplicates from that table such as below: enter image description here

However, if i select distinct Dyndom pdbcode from the table, it returns distinct values of that pdbcode. DynDom table and

CATH

根据以上情况,我对表格中的DynDom/CATH栏进行了评论,并对DynDom/CATH进行了单独处理,并相应地将这些数值退回,这是我需要的东西,我很想知道,我是否可以使用2个不同的说明,以纸浆编码为基础,将整个表格的不同价值回去。

我的法典如下:

select DISTINCT
    cath_dyndom_table_2."DYNDOM_DOMAINID",
    cath_dyndom_table_2."DYNDOM_DSTART",
    cath_dyndom_table_2."DYNDOM_DEND",
    cath_dyndom_table_2."DYNDOM_CONFORMERID",
    cath_dyndom_table_2.pdbcode,
    cath_dyndom_table_2."DYNDOM_ChainID",
    cath_dyndom_table_2.cath_pdbcode,
    cath_dyndom_table_2."CATH_BEGIN",
    cath_dyndom_table_2."CATH_END"
from 
    cath_dyndom_table_2 
where 
    pdbcode =  2hun 
order by 
    cath_dyndom_table_2."DYNDOM_DOMAINID",
    cath_dyndom_table_2."DYNDOM_DSTART",
    cath_dyndom_table_2."DYNDOM_DEND",
    cath_dyndom_table_2.pdbcode,
    cath_dyndom_table_2.cath_pdbcode,
    cath_dyndom_table_2."CATH_BEGIN",
    cath_dyndom_table_2."CATH_END";

最后,我要根据制版编码,从DynDom和CATH处搜索田地,并在没有重复值的情况下将电网退回。

谢谢。

UPDATE :

这是我已做的要务表。

    CREATE VIEW cath_dyndom_table AS
SELECT
  r.domainid AS "DYNDOM_DOMAINID",
  r.DomainStart AS "DYNDOM_DSTART",
  r.Domain_End AS "DYNDOM_DEND",
  r.ddid AS "DYN_DDID",
  r.confid AS "DYNDOM_CONFORMERID",
  r.pdbcode,
  r.chainid AS "DYNDOM_ChainID",
  d.cath_pdbcode,
  d.cathbegin AS "CATH_BEGIN",
  d.cathend AS "CATH_END"
FROM dyndom_domain_table r
  FULL OUTER JOIN cath_domains d ON d.cath_pdbcode::character(4) = r.pdbcode 
  ORDER BY confid ASC;
最佳回答

如果你希望从每个桌上就域名和地域范围达成联合国决定,那么就能够做到:

SELECT DYNDOM_DOMAINID, DYNDOM_DSTART, DYNDOM_DEND
FROM DynDom
UNION
SELECT RTRIM(cath_pdbcode), CATH_BEGIN, CATH_END
FROM CATH

这应当消除准确的重复(例如,域名、起步和终点完全相同),但不会消除不同范围重复的域名——如果存在的话,你需要决定如何处理这些域名(将它们作为单独条目加以保留,将其与最低的起步和最高终点相结合,或选择任何其他办法)。

EDIT:实际上,我认为你能够仅仅通过改变日本宇宙开发网的条件,取得预期结果,以便:

FULL OUTER JOIN cath_domains d 
ON d.cath_pdbcode::character(5) = r.pdbcode || r.chainid AND
   r.DomainStart <= d.cathbegin AND
   r.Domain_End >= d.cathend
问题回答

你们正在做的是“两个表格”的<条码>。

为使一条没有重复的线路,有必要在<代码>1-to-1链接上在tables之间架设<>。


参看HERE,什么是cartesian并入 rel=“nofollow”HERE 如何避免!





相关问题
摘录数据

我如何将Excel板的数据输入我的Django应用? I m将PosgreSQL数据库作为数据库。

Postgres dump of only parts of tables for a dev snapshot

On production our database is a few hundred gigabytes in size. For development and testing, we need to create snapshots of this database that are functionally equivalent, but which are only 10 or 20 ...

How to join attributes in sql select statement?

I want to join few attributes in select statement as one for example select id, (name + + surname + + age) as info from users this doesn t work, how to do it? I m using postgreSQL.

What text encoding to use?

I need to setup my PostgreSQL DB s text encoding to handle non-American English characters that you d find showing up in languages such as German, Spanish, and French. What character encoding should ...

SQL LIKE condition to check for integer?

I am using a set of SQL LIKE conditions to go through the alphabet and list all items beginning with the appropriate letter, e.g. to get all books where the title starts with the letter "A": SELECT * ...

热门标签