Home » SQL & PL/SQL » SQL & PL/SQL » Required query analysis..
Required query analysis.. [message #213088] Tue, 09 January 2007 07:59 Go to next message
naga1709
Messages: 5
Registered: January 2007
Junior Member

SELECT account_id, NVL(previous_balance, 0) * .009 finance_charge,
NVL(new_purchases, 0) + (NVL(previous_balance, 0) * 1.009) - NVL(payments, 0)
"current balance"
FROM account
WHERE (new_purchases + (previous_balance * 1.009)) - payments > "credit_limit"
AND account_id BETWEEN 1500 AND 2000;


I need a query that would display records from 1550 to 2000 and their current balance is greater than credit_limit..

Is the above query correct ... i dint use nvl function to check condition in where clause ..
Re: Required query analysis.. [message #213090 is a reply to message #213088] Tue, 09 January 2007 08:03 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Sorry if this sounds harsh, but this forum is not a testing utility.
What would you do? If I said "Yes it is correct", would you blindly throw it to production?
If you want to check if your query is correct, build testdata.
Re: Required query analysis.. [message #213091 is a reply to message #213088] Tue, 09 January 2007 08:06 Go to previous message
vamsi kasina
Messages: 2108
Registered: October 2003
Location: Hyderabad, India
Senior Member
If you want to consider the NULL values as zeroes, you need to use nvl with 0.
if you have NULL values in any of the column previous_balance, new_purchases and payments and you haven't specified the nvl function, it will be treated as NULL.

By
Vamsi
Previous Topic: dislaying a number in timestamp format
Next Topic: Performance Issue
Goto Forum:
  


Current Time: Sat Aug 19 12:01:02 CDT 2017

Total time taken to generate the page: 0.14332 seconds