Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with count

Status
Not open for further replies.

dreamboy27

Programmer
Sep 25, 2006
16
0
0
US
I have a table with 4 cols and i want to count by grouping.Here is my example.

planner supp loc shipment

MA23242 JOHN 01 TA
MA23242 JOHN 01 TA
MA23242 JOHN 01 TE
MA23242 JOHN 02 TR
MA23111 JIMM 02 TA
MA23111 JIMM 02 TR
MA23111 JIMM 02 TE
MA28888 DAVE 01 TR
MA28888 DAVE 01 TR
MA28888 DAVE 01 TR

HERE IS MY DATA BASE:
and my result chould be

planner supp loc TA TE TR

MA23242 JOHN 01 2 1 0
MA23242 JOHN 02 0 0 1
MA23111 JIMM 02 1 1 1
MA28888 DAVE 01 0 0 3


I NEED A SQL STATEMENT PLEASE AND THE TABLE I AM USING IS A HUGE TABLE

 
Select
planner,
supp,
loc,
sum(decode(shipment,'TA',1,0)) TA,
sum(decode(shipment,'TE',1,0)) TE,
sum(decode(shipment,'TR',1,0)) TR
from {your table}
group by planner, supp, loc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top