jalil jalal

jalil jalal

  • NA
  • 31
  • 538

src Pivot sql with parametrs

Mar 16 2018 1:09 PM
Hello,
 
I just did advanced actions in SQL, but I found some difficulty. In short, I want to display some data (name, grade, and premium date) between two dates (Start and End), but by rotating the date to have a display as a result
 
 
My request is :
  1. SELECT * FROMSELECT E.LastName + ', ' + e.FirstName as name ,E.grade ,t.Date d FROM table e )src pivot( max(d) for d IN ([2017-12-18 00:00:00.000] ,[2017-12-19 00:00:00.000] ,[2017-12-20 00:00:00.000] ,[2017-12-21 00:00:00.000] ) ) as p  
All is well, but what I want to do is enter a start and end date as parameters instead of putting the dates in the for d in (...) clause. And the dates that will be rotated must be within this set date range.
 
I tried to create a parameterized procedure and put it in for IN (MyProc) but it does not work and thank you in advance for your cooperation

Answers (1)