Greeting, as seen on many post here and there that sub-queries is slower than join...
but i can't find a way to make following query using any join method.. so, i used sub-queries.
can any one tell me how to use join correctly for following case:
table1:
customerID, Name
1, abc
2, xyz
3, qwe
4, zxc
5, asd
and so on
table2:
customerID, Month, OrderNumbers
1, jan, 5
1, feb, 6
2, jan, 8
3, feb, 5
4, mar, 3
and so on..
i need to make report like this:
customer id, name, jan order, feb order, mar order
1, abc, 5, 6, 0
2. xyz, 8, 0, 0
3. qwe, 0, 5, 0
and so on
i am using this query:
select table1.customerID,
table1.Name,
(select table2.Month as jan
where table2.Month = jan),
(select table2.Month as feb
where table2.Month = feb),
(select table2.Month as mar
where table2.Month = mar)
from table1
but this not working as it should...
so, how can i achieve that?