January 19, 2020 at 12:03 pm
this is my query, which gives me the complains details
SELECT *
FROM CI_TD_ENTRY TE
INNER JOIN CI_TD_DRLKEY CTD
ON(TE.TD_ENTRY_ID = CTD.TD_ENTRY_ID)
INNER JOIN CI_CASE CC
ON (CTD.KEY_VALUE = CC.CASE_ID);
Now i want to know,
I believe it can be done through pivot but i do not know how to do it.
Need help??
January 19, 2020 at 7:02 pm
I personally don't advocate the use of the PIVOT operator because it's not friendly and it's frequently almost twice as slow as the old "Black Arts" method of doing a CROSSTAB.
Here's an article on both methods.
Here's a follow-up article on how to do it dynamically.
https://www.sqlservercentral.com/articles/cross-tabs-and-pivots-part-2-dynamic-cross-tabs
--Jeff Moden
Change is inevitable... Change for the better is not.
January 21, 2020 at 3:32 pm
In addition, PIVOT
can only do one aggregate, but you need two different aggregates in this example:
Crosstabs are more flexible in addition to what Jeff already said about them being easier and faster.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply