vendredi 31 juillet 2015

retrieve value from sql statement for later use

How can I retrieve the value of TOTAL from the SQL statement below in c# and save it as a variable for use in a following query ?

SELECT  detail.branch, SUM(CONVERT(DECIMAL(8, 2), detail.total)) AS TOTAL, 
        SUM(CONVERT(DECIMAL(8, 2),detail.typeA / 1.2)) AS TA, 
        COUNT(DISTINCT detail.orderid) AS NOR, 
        SUM(DISTINCT header.coupon) AS coupon
FROM    detail INNER JOIN header ON detail.filename = header.filename
WHERE   detail.dates BETWEEN '04/01/2015' AND '04/30/2015' AND branch='SW1'
GROUP BY detail.branch

Aucun commentaire:

Enregistrer un commentaire