ambuli

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.

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

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.

ASKER CERTIFIED SOLUTION

membership

This solution is only available to members.

To access this solution, you must be a member of Experts Exchange.