Hi, I am trying to set up a query that makes a value positive i is is a certain transaction.
Trying to set it up in a sproc but I just don't seem to make it work. What am I doing wrong here?
Thanks,
Linkan
DECLARE @lngType int
SELECT @lngType = (SELECT lngType FROM vLinkanTestView)
IF @lngType = '2'
BEGIN
SET NOCOUNT ON
SELECT strPosCode, SUM((lngPrice)-(lngPrice)-(lngPrice)) AS lngPrice, strName FROM vLinkanTestView WHERE lngType = '2' GROUP BY strPosCode, strName
END
ELSE
BEGIN
SET NOCOUNT ON
SELECT strPosCode, SUM(lngPrice) AS lngPrice, strName FROM vLinkanTestView WHERE lngType <> '2' GROUP BY strPosCode, strName
END
Trying to set it up in a sproc but I just don't seem to make it work. What am I doing wrong here?
Thanks,
Linkan
DECLARE @lngType int
SELECT @lngType = (SELECT lngType FROM vLinkanTestView)
IF @lngType = '2'
BEGIN
SET NOCOUNT ON
SELECT strPosCode, SUM((lngPrice)-(lngPrice)-(lngPrice)) AS lngPrice, strName FROM vLinkanTestView WHERE lngType = '2' GROUP BY strPosCode, strName
END
ELSE
BEGIN
SET NOCOUNT ON
SELECT strPosCode, SUM(lngPrice) AS lngPrice, strName FROM vLinkanTestView WHERE lngType <> '2' GROUP BY strPosCode, strName
END