select doctype,docid,pro_type,create_date from TSPRO_SALESROOM_STOCKIN_MAIN where CREATE_DATE>'2011-02-01' and CREATE_DATE<='2011-02-28'
select count(*) from TSPRO_SALESROOM_STOCKIN_MAIN where CREATE_DATE>'2011-02-01' and CREATE_DATE<='2011-02-28' and pro_type=2
SELECT pro_type,
[1] AS JAN,
[2] AS FEB,
[3] AS MAR,
[4] AS APR
from (
select pro_type,DATEPART(MM,create_date) AS MON
from TSPRO_SALESROOM_STOCKIN_MAIN where CREATE_DATE>'2011-01-20' and CREATE_DATE<='2011-03-09'
)s
PIVOT
(
COUNT(MON) FOR MON IN ([1],[2],[3],[4])
)AS p