Guest User

Untitled

a guest
Apr 15th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 1.96 KB | None | 0 0
  1. -- größte Dateien mit Download-History
  2. select
  3.    x.*, y.ZeitpunktLastDownload, y.AnzahlDownload
  4. from (
  5.    select top 1000
  6.       b.Name as Bereich, f.Name + '.' + t.Name as Name,
  7.       f.Size / 1024.0 / 1024.0 as SizeInMb, f.DatumErstell, f.IdFile
  8.    from TFile f
  9.       join TFileTypFile t
  10.          on t.TypFile = f.TypFile
  11.       join TFileTypBereich b
  12.          on b.TypBereich = f.TypBereich
  13.    order by
  14.       f.Size desc
  15.    ) x
  16.    left join (
  17.       select
  18.          IdFile, max(Zeitpunkt) as ZeitpunktLastDownload, count(*) as AnzahlDownload
  19.       from TFileLog
  20.       where
  21.          Info = 'Download OK'
  22.       group by
  23.          IdFile
  24.    ) y
  25.       on y.IdFile = x.IdFile
  26. order by
  27.    x.SizeInMb desc
  28.  
  29.  
  30.  
  31. -- größte Dateien mit Download-History
  32. select
  33.    x.*, y.ZeitpunktLastDownload, y.AnzahlDownload
  34. from (
  35.    select top 1000
  36.       b.Name as Bereich, f.Name + '.' + t.Name as Name,
  37.       f.Size / 1024.0 / 1024.0 as SizeInMb, f.DatumErstell, f.IdFile
  38.    from TFile f
  39.       join TFileTypFile t
  40.          on t.TypFile = f.TypFile
  41.       join TFileTypBereich b
  42.          on b.TypBereich = f.TypBereich
  43.    where
  44.       f.Size / 1024.0 / 1024.0 > 0.5
  45.    order by
  46.       f.IdFile desc
  47.    ) x
  48.    left join (
  49.       select
  50.          IdFile, max(Zeitpunkt) as ZeitpunktLastDownload, count(*) as AnzahlDownload
  51.       from TFileLog
  52.       where
  53.          Info = 'Download OK'
  54.       group by
  55.          IdFile
  56.    ) y
  57.       on y.IdFile = x.IdFile
  58. order by
  59.    x.IdFile desc
  60.  
  61. -- hinzukommende Dateien pro Tag:
  62. select top 300
  63.    cast(DatumErstell as date) as Datum, sum(Size / 1024.0 / 1024.0) as SizeInMb
  64. from TFile
  65. group by
  66.    cast(DatumErstell as date)
  67. order by
  68.    1 desc
  69.  
  70. -- hinzukommende Dateien pro Monat: seit 2011 mind. 2 GB pro Monat
  71. select
  72.    year(DatumErstell) as Jahr, month(DatumErstell) as Monat, sum(Size / 1024.0 / 1024.0) as SizeInMb
  73. from TFile
  74. group by
  75.    year(DatumErstell), month(DatumErstell)
  76. order by
  77.    1 desc, 2 desc
Add Comment
Please, Sign In to add comment