wood burning stoves 2.0*
The moose likes JDBC and the fly likes SUM using two attributes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
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
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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