title: Use where clause in temporary table
body: <p>I am trying to use where clause in temporary table. Actually i used it but results aren't true. trying to find products between 2 dates but when i use where clause it gets no data. </p>
  
  <pre><code>CREATE TABLE #TEMPCOZGU
  (
      ROW INT,
      TEZGAH VARCHAR(50),
      COZGU VARCHAR(50),  
      PERSONEL VARCHAR(50),
      DATE DATETIME,
      FIRE INT,
      FIRE_METRE NUMERIC(25,6)
  )
      INSERT INTO #TEMPCOZGU
  
  select row_number() over(order by TEZGAH) AS ROW, TEZGAH, COZGU, PERSONEL, TARIH, FIRE, FIRE_METRE  
  from cozgu_fırelerı 
  where tezgah = 'M01' and cozgu = 'SAĞ ALT BAĞLANTI'
  
  
  
  SELECT  T1.TEZGAH, T1.COZGU, T1.PERSONEL,T1.FIRE, T1.FIRE_METRE, t1.DATE, T2.DATE AS PREVIOUSDATE, ISNULL(DATEDIFF(DAY, T2.DATE, T1.DATE), 0) AS GUNFARKI  , SUM(MKARE) AS TOPLAMMKARE
  FROM #TEMPCOZGU as t1
  left outer join #TEMPCOZGU as t2 on t1.row-1 = t2.row
  left outer join HALI_TEZGAH AS TE ON T1.TEZGAH = TE.TEZGAH_NO
  LEFT OUTER JOIN HALI_GUNLUK_URETIM AS U ON U.TEZGAH = TE.ID 
  --WHERE U.TARIH BETWEEN T1.TARIH AND T2.TARIH
  GROUP BY  T1.TEZGAH, T1.COZGU, T1.PERSONEL, T1.DATE,T1.FIRE, T1.FIRE_METRE, T2.DATE
  
  drop table #TEMPCOZGU`
  </code></pre>