sql server 2005 - SQL Pivot based on value between two columns -
I have a table in which I have two columns, among other things, for a start date and the other end date for. I have to write a question which will return a column for each month of the year and the value of that column is 1 if the month is between 0. PIVOT statement What I see here, but best I can tell PIVOT section is looking to match values, do not check that the value is between the other two or not Whether the PIBT clause is constructed correctly Or do I need to break and write details of 12 cases and then add them?
I think there are three basic steps I get here:
- Get a date in every 12 months
- Check whether this date is between start and end date
- The result of PIVOT
From here I can include this table with the table which I really care about. Then I use the date where any entry starts and ends to start not related to that month. Then select something like this:
Join the titles, month (months) cross, where others during the months. Start and other .end
In this phase, we should be careful that we select only the columns, which will result in the desire to become extinct, or that will be collected using the PVOT statement. Finally, we should get the result:
PIVOT (for PID) IN IN ([1], [2], [3], [ 4], [5], [6], [7], [8], [9], [10], [11], [12])
Something can look like:
I have snatched all the other complications that I went through to include other information , So I have not really written this question, but must be taught the original query structure, which was the result I needed.
Comments
Post a Comment