This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes SUM using two attributes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "SUM using two attributes" Watch "SUM using two attributes" New topic
Author

SUM using two attributes

rahull agarwal
Ranch Hand

Joined: Dec 20, 2010
Posts: 31
Hi,

My table has two columns amount and amountEstimated.

I would like to get a sum of the money using following logic.

If (amount == null) use amountEstimated
Else use amount.

How do I write a SQL for this?

Thanks so much for your help
Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19747
    
  10

That depends on what database you are using. Here is a page which gives examples for a couple of the more common databases.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SUM using two attributes
 
It's not a secret anymore!