SQL To Count If It Is Greater Than 1

-1

My problem is this:

I have to make a condition if the SEQ_VENDA has more than 001 NUMBER, it bring the SELECT data. And if you have only 1 NUMBER referring to SEQ_VENDA do not bring in SQL

    
asked by anonymous 23.10.2018 / 15:09

1 answer

3

returns a line and how many times (SQL Para Contar Se for Maior Que 1)

SELECT *,
       count(*) AS c
FROM ITENS_VENDA
GROUP BY SEQ_VENDA
HAVING c > 1
ORDER BY c DESC

If you want the full lines

select * from ITENS_VENDA where SEQ_VENDA in (
    select SEQ_VENDA from ITENS_VENDA
    group by SEQ_VENDA having count(*) > 1
)

Example table

Result

    
23.10.2018 / 15:23