The forum will experience an outage sometime between February 10 at 7:00pm EST and February 12 at 11:59 EST for installation of security updates. The actual time and duration of the outage are unknown but attempts will be made to minimize the downtime. We apologize for any inconvenience.

Hi Fellows,

As you can see, I'm giving you a bit of work.
Definitely I could not find a way to do this on the web, I'd googleit a lot.
I have a query on multiple tables, there is a factor multiplied by the quantity that will return a final value.
This factor could be in the standard table or can be negotiated by the seller.
If it is negotiated, has precedence over the value on standard table.
I tried something like this above but does not work.

select codProduct,
if negociatedValue > 0 then (or is not null)
   negociatedValue * quantity
   standardValue * quantity
from sales ...

asked 22 Jun '12, 16:26

RDPSispetro's gravatar image

accept rate: 0%

I just found a way to do it, but with case and using alias, like ...

select codProduct, quantity, case when negociatedValueis not null then negociatedValue * quantity else standardValue * quantity end from sales ...

(22 Jun '12, 16:36) RDPSispetro

I would prefer the isnull() function - or coalesce(), which works the same here but is standard SQL:

select codProduct, quantity, isnull(negociatedValue, standardValue) * quantity
from sales ...
permanent link

answered 26 Jun '12, 03:19

Volker%20Barth's gravatar image

Volker Barth
accept rate: 32%

This might work:

select codProduct,
if negociatedValue > 0 then (or is not null)
   negociatedValue * quantity
   standardValue * quantity
from sales ...
permanent link

answered 22 Jun '12, 17:29

Elmi%20Eflov's gravatar image

Elmi Eflov
accept rate: 31%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 22 Jun '12, 16:26

question was seen: 1,376 times

last updated: 26 Jun '12, 03:19