Tech_Men
asked on
i need to get all the sum that are <0 and the ActSum >0 only
this is the code in the sqlCommand :
SELECT SUM(Actions.ActionSum) AS ActSum, Actions.CustId, COUNT(*) AS Expr2, Customers.CustRunID, Customers.CustName, Customers.CustAddres,
Customers.CustCity, Customers.CustPhone, Customers.CustFax, Customers.CustCell, Customers.CustRemarks
FROM Actions INNER JOIN
Customers ON Actions.CustId = Customers.CustRunID
WHERE (ActSum < 0) // not working its says that this colum ActSum is invalid
GROUP BY Actions.CustId, Customers.CustRunID, Customers.CustName, Customers.CustAddres, Customers.CustCity, Customers.CustPhone,
Customers.CustFax, Customers.CustCell, Customers.CustRemarks
i need to pull out only the rows that the ActSum is <=0
how can i do it ?
thanks !!!
SELECT SUM(Actions.ActionSum) AS ActSum, Actions.CustId, COUNT(*) AS Expr2, Customers.CustRunID, Customers.CustName, Customers.CustAddres,
Customers.CustCity, Customers.CustPhone, Customers.CustFax, Customers.CustCell, Customers.CustRemarks
FROM Actions INNER JOIN
Customers ON Actions.CustId = Customers.CustRunID
WHERE (ActSum < 0) // not working its says that this colum ActSum is invalid
GROUP BY Actions.CustId, Customers.CustRunID, Customers.CustName, Customers.CustAddres, Customers.CustCity, Customers.CustPhone,
Customers.CustFax, Customers.CustCell, Customers.CustRemarks
i need to pull out only the rows that the ActSum is <=0
how can i do it ?
thanks !!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You have to specify the 'where' part of the SQL in the 'having' section..
So it will appear like..
SELECT SUM(Actions.ActionSum) AS ActSum, Actions.CustId, COUNT(*) AS Expr2, Customers.CustRunID, Customers.CustName, Customers.CustAddres,
Customers.CustCity, Customers.CustPhone, Customers.CustFax, Customers.CustCell, Customers.CustRemarks
FROM Actions INNER JOIN
Customers ON Actions.CustId = Customers.CustRunID
GROUP BY Actions.CustId, Customers.CustRunID, Customers.CustName, Customers.CustAddres, Customers.CustCity, Customers.CustPhone,
Customers.CustFax, Customers.CustCell, Customers.CustRemarks
HAVING sum(Actions.ActionSum)<0
Smg
So it will appear like..
SELECT SUM(Actions.ActionSum) AS ActSum, Actions.CustId, COUNT(*) AS Expr2, Customers.CustRunID, Customers.CustName, Customers.CustAddres,
Customers.CustCity, Customers.CustPhone, Customers.CustFax, Customers.CustCell, Customers.CustRemarks
FROM Actions INNER JOIN
Customers ON Actions.CustId = Customers.CustRunID
GROUP BY Actions.CustId, Customers.CustRunID, Customers.CustName, Customers.CustAddres, Customers.CustCity, Customers.CustPhone,
Customers.CustFax, Customers.CustCell, Customers.CustRemarks
HAVING sum(Actions.ActionSum)<0
Smg
WTF ? you split the points between someone who didn't get the right answer and someone who said the same as me (albeit a minute before). Surely a point split between the two people who answered correctly would be more fair ?
ASKER
ohhhhhh i am so sorry :(
i didint paid attention because someone interrupt me when i did it
what can i do to make u up ?
i am terrible terrible sorry
can i do something to correct this mistake ?
please tell me how
i didint paid attention because someone interrupt me when i did it
what can i do to make u up ?
i am terrible terrible sorry
can i do something to correct this mistake ?
please tell me how
ASKER
its not working