Skip to content
Advertisement

How to cut a table?

How can I reduce that table in Oracle’s SQL:

PersonNr   TestID    Date          resultTestA    resultTestB
Person1     1        01.01.19        pos
Person1     1        01.01.19                       neg
Person1     2        02.02.19        pos
Person2     3        02.02.19        neg           
Person2     4        02.02.19        neg

The result must be:

PersonNr   TestID    Date          resultTestA    resultTestB
Person1     1        01.01.19        pos             neg             
Person1     2        02.02.19        pos
Person2     3        02.02.19        neg             
Person2     4        02.02.19        neg

Advertisement

Answer

use aggregation

PersonNr,TestID,Date,max(resultTestA),max(resultTestB)
from table group by PersonNr,TestID,Date
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement