Hi,

I'm using this SQL statement to retrieve Value and Date which will then be plotted on a graph:

SELECT DISTINCT assets.SEDOL,assets.Quantity,stock_names.value,stock_names.Fileid,date_header.dateid 
FROM assets,stock_names,date_header 
WHERE assets.Client_ref = '$clientref' AND stock_names.SEDOL = assets.SEDOL 
AND date_header.fileid = stock_names.fileid

I'm also selecting Quantity. Instead of having to multiply out the arrays, how can I multiply value and quantity inside the SQL statement and then just return Value (multiplied by quantity)?

Use assets.Quantity * stock_names.value as Price .IN SELECT QUERY.you can use simple arithmetic operators on two number.

SELECT DISTINCT assets.SEDOL,assets.Quantity,stock_names.value,stock_names.Fileid,date_header.dateid ,assets.Quantity*stock_names.value as Price
FROM assets,stock_names,date_header 
WHERE assets.Client_ref = '$clientref' AND stock_names.SEDOL = assets.SEDOL 
AND date_header.fileid = stock_names.fileid

Just use (assets.Quantity * stock_names.value) as Total

commented: :) +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.