Link to home
Start Free TrialLog in
Avatar of ambuli
ambuliFlag for United States of America

asked on

SQL select for total values of columns

Hi there,
I have a table that looks like below.

Line, Amount, Type
303, 20, OUT
300, 10, OUT
301, 20, IN
301, 10, OUT
300, 10, IN
300, 30, OUT
300, 20, IN
301, 10, IN
300, 40, IN
I want to generate the following data( Basically for each line find the total number of times it appears
as IN and OUT as well as the total values of the amount for each Line.

Line, NumIN, NumOUT, TotalInAmount, TotalOutAmount
300, 3, 2, 70, 40
301, 2, 1, 30, 10
303, 0, 1, 20

How can I generate this using a single SQL Query.  Thank you.
SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial