0
我有以下表格,我希望根據不同類型的編號獲得結果,每CONTRACT_ID可用。Oracle - 根據列值進行篩選
表:
______________________________________________________________________________________
|Source | CONTRACT_ID | TYPE | ADDRESS | PHONE |
______________________________________________________________________________________
|Source1 | 1234 | INSURED | unique1 | 4321 |
______________________________________________________________________________________
|Source1 | 1234 | INSURED | unique1 | 4321 |
______________________________________________________________________________________
|Source1 | 1234 | DRIVER | unique1 | 4321 |
______________________________________________________________________________________
|Source1 | 1234 | INSURED | unique1 | 4321 |
______________________________________________________________________________________
|Source2 | 2345 | INSURED | unique2 | 5678 |
______________________________________________________________________________________
|Source2 | 2345 | DRIVER | unique2 | 5678 |
______________________________________________________________________________________
|Source2 | 2345 | CONTRACT | unique2 | 5678 |
______________________________________________________________________________________
結果:
______________________________________________________________________________________
|Source | CONTRACT_ID | ROLES | ADDRESS | PHONE |
______________________________________________________________________________________
|Source1 | 1234 | 2 | unique1 | 4321 |
______________________________________________________________________________________
|Source2 | 2345 | 3 | unique2 | 5678 |
______________________________________________________________________________________
即在結果表中的ROLES列應爲不同TYPE S的一個獨特的數CONTRACT_ID。
任何人都可以幫忙嗎?
你到目前爲止嘗試過什麼? –
我已經衝浪,但仍然無法得到如何計算不同的varchar值@KaushikNayak的數量! – Nidheesh