MYSQL client report

Asked

Viewed 54 times

1

Good afternoon, gentlemen, all right? I’m facing a problem and I can’t solve it.

Below is an example of my database structure:

exemplo de como encontra-se a estrutura do banco de dados

I need to make a MYSQL script that selects people that contain the following conditions:

1 - PESSOA_ENDERECO.UF = "MS"

2 - PESSOA_EMPRESTIMO.DATA_TERMINO > NOW()

3 - PESSOA_EMPRESTIMO.TIPO_EMPRESTIMO = 'CARD'

4 - PESSOA_EMPRESTIMO.CODIGO_BANCO = '0001'

(that’s the part I’m not getting) 5 - HAVING A MARGIN AVAILABLE IN EXCESS OF A SPECIFIC PERCENTAGE;

The margin available shall be calculated as follows::

35% of the value found in PESSOA_BENEFICIO.VALUE less the sum of all VALOR_PARCELA of the benefit in question.

that is, if the person receives 1300 benefits, the margin is 455; the available margin of it would be 455 less the sum of all the installments of the loans that she owns.

  • Welcome to Stack Overflow! Please enter the query code you’ve created so far. This can help you find an answer.

  • I just got off work, tomorrow at the first time put the script I have so far!

  • select pessoa.* from pessoa_endereco left Join pessoa on pessoa.id = pessoa_endereco.pessoa_id right Join pessoa_emprestimo on pessoa_emprestimo.pessoa_id = pessoa.id Where pessoa_endereco.estado = 'MS' and pessoa_emprestimo.banco = '0001' and pessoa_emprestimo.tipo_emprestimo = 'CARD' group by pessoa_id limit 10

No answers

Browser other questions tagged

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