title: The Declare SQL construct or statement is not supported
body: <p>While using the query shown, I get an error. </p>
  
  <blockquote>
    <p>The Declare SQL construct or statement is not supported.</p>
  </blockquote>
  
  <p>Help me to find a proper solution.</p>
  
  <pre><code>DECLARE @maxcount1 float 
  DECLARE @maxcount0 float 
  DECLARE @start datetime 
  SET @start = getdate() - 2 
  DECLARE @end datetime 
  SET @end= getdate() + 2
  
  SELECT @maxcount1 = max(OnTimeCount),@maxcount0 = max(DueTimeCount)
  
  FROM  (SELECT DISTINCT COUNT(DISTINCT CASE WHEN ontime = 1 THEN sl_no  END)  AS OnTimeCount,  COUNT(DISTINCT CASE WHEN ontime = 0 THEN  sl_no END) AS DueTimeCount FROM tbl_splited_details 
  
  WHERE (uploaded_date  BETWEEN  @start  AND @end) GROUP BY Site_ID) AS s
  
  SELECT  DISTINCT Site_ID, OnTimeCount, DueTimeCount, 
  round((cast((OnTimeCount*100) AS float)/@maxcount1), 2)AS percentage1 , round((cast((DueTimeCount *100)AS float)/@maxcount1),  2) AS percentage0
  
  FROM (SELECT DISTINCT  Site_ID, COUNT(DISTINCT CASE  WHEN ontime  =   1  THEN  sl_no  END)  AS OnTimeCount, 
  COUNT(DISTINCT CASE WHEN ontime  =  0 THEN sl_no END) AS  DueTimeCount  
  
  FROM  tbl_splited_details  WHERE (uploaded_date BETWEEN  @start  AND    @end)   GROUP BY    Site_ID) AS s                                    
  </code></pre>