Duda SQLITE query

0

I have a table that stores me that stores three numbers and an ID.

NUMERO1    NUMERO2    NUMERO3    ID  
 14070     4641       24155      1  
 14070     4780       24155      2  
 14070     4333       24155      3  
 15000     4303       24000      2  
 16000     4003       17000      1  

I would like to get those records that have same number1 and number 3 but with more than one ID. That is, I would like to take only these three records

 NUMERO1    NUMERO2    NUMERO3    ID   
 14070       4641       24155     1   
 14070       4780       24155     2   
 14070       4333       24155     3   

I've tried with the following query, but it does not work for me, I do not know what I'm doing wrong with

SELECT 
    NUMERO1, NUMERO2, NUMERO3, ID 
FROM 
    TABLA 
GROUP BY 
    (NUMERO1, NUMERO3, ID) 
HAVING 
    COUNT(ID)>1
    
asked by painkillerpucela 21.03.2017 в 13:35
source

1 answer

0

It should not be like this:

SELECT 
    NUMERO1, NUMERO2, NUMERO3, ID 
FROM 
    TABLA 
GROUP BY 
    (NUMERO1, NUMERO3) 
HAVING 
    COUNT(ID)>1

Removing the GROUP BY ID I think you get the result you're looking for.

    
answered by 21.03.2017 в 14:12