In a database exercise I get a DB with which I must take 2 tables TBL_AMIGOS
and TBL_ESTATUS_SOLICITUDES
to make a query to know the user with the largest number of confirmed requests.
I've tried with HAVING
and COUNT
but I'm using it badly.
TBL_AMIGOS
-
CODIGO_USUARIO
-
CODIGO_AMIGO
-
CODIGO_ESTATUS
-
CODIGO_TIPO_RELACIO
TBL_ESTATUS_SOLICITUDES
-
CODIGO_ESTATUS
-
NOMBRE_ESTATUS
The tables to be used are in the upper left corner of the relational model.
For a friendship to be confirmed in the record of TBL_AMISTADES
the CODIGO_ESTATUS
must be equal to 1
which means CONFIRMADA
as seen in the image. In case what I need is to know that USER has the most amount of 1
in the field CODIGO_ESTATUS
.
Thank you.