This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Alternate SQL

 
Hasan Pasha
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a SQL query that would work in Oracle... but if I change the DB then it would not work as I am using Oracle specific fn. (NVL).

I do not have much of an experience with writing SQL queries.
Some one please help me rewrite a generic query that would work on all DB.

My oracle specific query is given below.

Thanks

 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 35976
422
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hasan,
To write that in a non-Oracle specific way, you need a subquery that returns the fields that you are adding. Then you can sum up the ones that aren't null. For example (on a smaller query),

Start with a bare bones query like that and then gradually add the rest of your query on.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!