は私が重複したチャンネル(同じ名前と番号の行)を削除したいテーブルPostgreSQLのGROUP BYの問題
id | name | number | address
--------------+------------------+---------+-------------------------------------
1 | channel A | 0 | http://stream01
2 | channel B | 2 | http://stream02
3 | channel C | 16 | http://stream03
4 | channel B | 2 | http://stream04
5 | channel B | 16 | http://stream05
6 | channel C | 16 | http://stream06
7 | channel A | 7 | http://stream07
8 | channel A | 5 | http://stream08
9 | channel A | 0 | http://stream09
...etc
があるとします。しかし、結果に名前と番号とともに他の列が含まれているようにしたい。
問題はid
とaddress
重複を削除した後に選択する問題です。私は最初に見つけたものを選んで喜んでいます。したがって、たとえば、上記の表から結果が
id | name | number | address
--------------+------------------+---------+-------------------------------------
1 | channel A | 0 | http://stream01
2 | channel B | 2 | http://stream02
3 | channel C | 16 | http://stream03
5 | channel B | 16 | http://stream05
7 | channel A | 7 | http://stream07
8 | channel A | 5 | http://stream08
...etc
する必要があります私は、私はおそらく私のクエリでSELECT name,number FROM table GROUP BY name,number
をする必要があります実現し、クエリがSELECT id,name,number,address FROM (..)
を始める必要がありますが、私はただの方法を考えることはできません1つのクエリでこれを行います。
アイデア?
「削除」とは、行を削除するか、結果に表示しないことを意味しますか? –
結果に含まれていません。私はほとんどそれを持っている気がします - 'SELECT id、name、number、addressからのテーブルの選択(名前の選択、GROUP BYの名前からの数字の番号、数字の)AS j USING(名前、番号)'。あまり働かなかった。 – tbh1