Here is my code; I am getting and error when I try to count how many records are in the statement. What I am trying to do is a comparison of freight from year to year. Everything worked great until I added the Pro2003 - Pro2005 with the count. Below is my code, and above that is my error message. All I want to do is count how many record there are.ERRORServer: Msg 245, Level 16, State 1, Line 1Syntax error converting the nvarchar value '00006R3W80' to a column of data type int.CODE BELOWSelect id, Customer_name, Cost2003, Pcs2003, Wgt2003, Pro2003, Cost2004, Pcs2004, Wgt2004, Pro2003, Cost2005, Pcs2005, Wgt2005, Pro2005From ( Select Id, Customer_name, Cost2003 = sum(case when year([PRO DATE])=2003 then AMOUNT else 0 end), Pcs2003 = sum(case when year([PRO DATE])=2003 then PCS else 0 end), Wgt2003 = sum(case when year([PRO DATE])=2003 then WEIGHT else 0 end), Pro2003 = count(case when year([PRO DATE])=2003 then PRONUM else 0 end), Cost2004 = sum(case when year([PRO DATE])=2004 then AMOUNT else 0 end), Pcs2004 = sum(case when year([PRO DATE])=2004 then PCS else 0 end), Wgt2004 = sum(case when year([PRO DATE])=2004 then WEIGHT else 0 end), Pro2004 = count(case when year([PRO DATE])=2004 then PRONUM else 0 end), Cost2005 = sum(case when year([PRO DATE])=2005 then AMOUNT else 0 end), Pcs2005 = sum(case when year([PRO DATE])=2005 then PCS else 0 end), Wgt2005 = sum(case when year([PRO DATE])=2005 then WEIGHT else 0 end), Pro2005 = count(case when year([PRO DATE])=2005 then PRONUM else 0 end) From PRODETAIL Where [group] = 'STONERIDGE' Group by id, customer_name ) A
Thank for all the help in advance.