0

I wanted to multiply two values from two different tables.
I have a quantity filed stored in one table and a unit/rate field in another.
How can i write the sql statement based on a condition and store that multiplied result for further actions.

2
Contributors
2
Replies
16
Views
3 Years
Discussion Span
Last Post by G_Waddell
0

can anybody check this statement,if there is a mistake please do tell me.

cmd = New OleDbCommand("SELECT quantity * rate as VALUE FROM sub_pay_item_quantity,sub_pay_item_unit_rate" & _
                             "WHERE [sub_pay_item_quantity.sub item] and [sub_pay_item_unit_rate.sub item]='" & subitem & "' and [sub_pay_item_quantity.bridge type] ='" & bridgetype & "'" & _
                             "and [sub_pay_item_quantity.span]='" & span & "'", conn)
0

MSDN Multiply in SQL

Exactly as you have done there (providing both values are numeric data types,) just to be sure in case you get NULL values I would use the ISNULL function to return a zero if there is a NULL:

SELECT ISNULL(quantity,0) * ISNULL(rate, 0) as VALUE FROM 
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.