I have an extensive product database in SQL Server. I need to take 3 tables and combine them so that I have at the end a table with columns named after items of one table, with productid as rows with the field data concatenated data from 2 other tables. No mathematical functions are performed at all. Data is just collated.
1) Table 1 pdt_WebWidgets has 132 items I call "Widgets." Column names for the pivot crosstab will come from field labeltext. New widgets are occasionally added, so pivot must be able to include these new widgets as they are created.
2) Table 2 pdt_WebWidgetValue has over 7 million records, with fields ProductID, WidgetID, Value. pdt_WebWidgetValue.WidgetID=pdt_WebWidgetID
3) For [login to view URL] IN (2,6), we can join pdt_WebWidgetListBox (57,000 records) to pdt_WebwidgetValue ON
pdt_WebWidgetListBox.ID=[login to view URL]
AND (important)
pdt_Webwidgetlistbox.WidgetID=[login to view URL]
Again, this is only for items in Type=(2,6). For this WidgetType, we will concatenate the values in [login to view URL] as a comma-delimited list in the pivot fields. All other Types, we will just take the actual pdt_WebWidgetValue.Value. These should be single values, typically.
I already have a query that does this, but it can be very slow. I use a number of static temp tables to help build the data to get it ready and make it easier/faster for the crosstab to be built. I wanted to see if someone could design something that would run much faster, creating a static pivot table after collating the data, so I could reduce a number of steps in a SQL Server Agent Job.
Hello, I can for sure build your pivot query in most efficient way. Table of 7 million rows shouldn't represent such a big issue if properly indexed but as you want items to be the columns and columns must be defined in SQL Server pivot table, your solution with temp can surely be upgraded in something better performing. I usually use dynamic SQL which ends up as pretty good choice when it comes to dynamic pivot tables. If you would like me to do this for you, feel free to contact me. Thank you for the consideration and cheers!
$110 USD in 2 days
5.0 (37 reviews)
7.5
7.5
8 freelancers are bidding on average $148 USD for this job
Hello,
As an expert in SQL, i am very much interested to do this project. I am not fully clear about the requirements, but as you did it already, i think i can just optimize it to run faster. If you want me to do it, will you give me the database and the current query? Let's discuss more.
Thanks
Hi euroluxhome
Greetings !!
Hope you finds in good health !!
I saw your job post on www.freelancer.com and happy to assist you on same.
I will redesign and maintain your details into a professional manner.
Is it possible if we can discuss complete details of your project and then come to a final discussion.
Hello.
How are you?
I am highly interested to work on the "Advanced CrossTab/Pivot Query SQL Server".
I am a full stack website developer.
I have more than 7 years experience in "Microsoft SQL Server, SQL".
I will make sure the best quality service.
Let us work together.
Best regards, Yang L.
hi
I have good amount of knowledge about the SQL server. I can help you regarding your task.
I have gone through your requirement.
either you can share to me your query or I will write my self.
kindly give chance to me.