Wednesday, 18 September 2013

calculate the sum of two columns kategory

calculate the sum of two columns kategory

I Have 2 tables :
1. Table Master(Vehicle,Vehicle_Color) :
Vehicle Vehicle_Color
---------------------------
Car Black
Car Yellow
Car White
Car Orange
motorcyle Black
motorcyle Yellow
motorcyle White
motorcyle Orange
2. Table Data(Name,Vehicle,Vehicle_Color) :
Name Vehicle Vehicle_Color
-----------------------------------
Ony motorcycle white
Galih motorcycle white
Zening motorcycle black
Lia motorcycle yellow
Tika motorcycle yellow
Fredy car black
Kenzy car white
Arka car white
Nugraha car white
I want to select vehicle , vehicle_color and count the number of vehicles
and the color
query select vehicle,vehicle_color,(.....) as number from Master left join
data on .... result like this
Vehicle Vehicle_Color Number
--------------------------------------
Car Black 1
Car Yellow 0
Car White 3
Car Orange 0
motorcyle Black 1
motorcyle Yellow 2
motorcyle White 2
motorcyle Orange 0
is there any suggestion, to create query? Tq..

No comments:

Post a Comment