October 21, 2014 at 12:04 pm
I cannot seem to figure out where this error is. I am getting "Incorrect syntax near '('." It seems to be something in the pivot clause, but I can't figure it out. Thanks
Here is the code...
CREATE TABLE #T1 (
Territory_NM VARCHAR(100),
Product_Type VARCHAR(100),
ReportCount INT
)
--reports by region
INSERT INTO #t1
selectTerritory_NM, Product_Type, COUNT(Order_Product_ID) AS ReportCount
From[dbo].[DeliveredReportsSummary]
WHEREdeliveredDate >= '01/01/2014' AND deliveredDate < '11/01/2014'
Group BY Territory_NM, Product_Type
order by Territory_NM, Product_Type
select Territory_NM
,isnull([Litigation Premier],0) as [Litigation Premier]
,isnull([Litigation Gold],0) as [Litigation Gold]
,isnull([Patent Gold],0) as [Patent Gold]
,isnull([Patent Silver],0) as [Patent Silver]
,isnull([Expert Publications],0) as [Expert Publications]
,isnull([Expert News and Internet Activity],0) as [Expert News and Internet Activity]
from #T1
pivot (sum(ReportCount)
for Product_Type IN ([Litigation Premier],[Litigation Gold],[Patent Gold],[Patent Silver],[Expert Publications],[Expert News and Internet Activity]))
as productsByRegion
October 21, 2014 at 12:13 pm
Your pivot statement is correct, your syntax error might be elsewhere.
October 21, 2014 at 12:41 pm
Thanks Luis. I can't figure out where the syntax might be. Any further assistance?
October 21, 2014 at 12:50 pm
Do you have something else in your code? Are you missing an end?
October 21, 2014 at 12:54 pm
only line I left out was "drop table #t1" at the end. Thanks
October 21, 2014 at 1:36 pm
October 21, 2014 at 1:43 pm
I have neither in this block of code. WYSIWYG
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy