SQL: JOIN and Count Repeated Number

Asked

Viewed 33 times

0

Tabelas do Banco I need to join Table Client along with the Table Request and would like to compare the Client id. the client ID of the Client table, Along with what’s inside the order table in case the column Cliente_id in the Order table, and count within the Orders table how many times the customer ID repeats, for example in case the image would have to return 3, as it has 741,741,741 three times the customer id within the Order table.

1 answer

0


Just for that it is not necessary to join, just:

SELECT pedido.cliente_id, count(*) 
FROM pedido
HAVING (count(*) > 1)
GROUP BY pedido.cliente_id;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.