Case nestled inside another case

Asked

Viewed 964 times

0

I’m very doubtful about CASE NESTED I have to perform an interest calculation that depends on some variables and I’m not able to build this case, so I need your help to assemble it.

1º IF GETDATE()-1 is a minor (<) that E1_VENCREA the code must stop and put the value ZERO ( 0 ) because you still have time to pay, otherwise you should continue to SECOND QUESTION.


2º If the result of FIRST QUESTION for FALSE (meaning greater) should be verified whether CONVERT(VARCHAR,CONVERT(DATETIME, E1_BAIXA),103 is different (<>) of '01/01/1900'.


3º If the result of SECOND QUESTION for TRUE another check shall be made whether CONVERT(VARCHAR,CONVERT(DATETIME, E1_BAIXA),103) is larger (>) that CONVERT(VARCHAR,CONVERT(DATETIME,E1_VENCREA),103)


4º If the result of THIRD QUESTION for TRUE perform the following calculation SUM((E1_PORCJUR/100)*BALANCE)*DATEDIFF(DAY,E1_BAIXA,GETDATE())) if the THIRD QUESTION for PHONY perform that other calculation SUM(((E1_PORCJUR/100)*BALANCE)*DATEDIFF(DAY,E1_VENCREA,GETDATE()))


5th Now here goes back to the end of the SECOND QUESTION if he goes PHONY perform the following calculation SUM(((E1_PORCJUR/100)*BALANCE)*DATEDIFF(DAY,E1_VENCREA,GETDATE()))


6th Ready! Now the questions are over, just name the column with the name of INTEREST.


DATABASE IS SQL SERVER, TABLE STRUCTURE HERE DOWNLOAD DROPBOX TABLES

  • 2

    Is there any way to add the table structure? Welcome, it’s interesting tour to better understand the functioning of the website.

  • 1

    You can edit your question and post your query.

  • Also inform the BD in question as the syntax may vary

  • All right, I’ve put together the information you requested.

No answers

Browser other questions tagged

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