SELECT t0.Datum,
t0.DMC,
t0.Produkt,
t1.[Wert] AS Gain,
t2.[Wert] AS [Min],
t3.[Wert] AS [Max],
t4.[Wert] AS [Offset],
t5.[Wert] AS Rough,
t6.[Wert] AS Rough_min
FROM (select Measures.dt as Datum, DMC, productidentifier as Produkt,MeasureDefinitions.Description, itemvalue as Wert from Measures join MeasureDefinitions on fk_dataItem = MeasureDefinitions.id
join Tracking on fk_tracking = Tracking.id
join TrackingIDs on fk_dmcId = TrackingIDs.id
join StationDefinitions on Tracking.fk_datagroup = StationDefinitions.id
join ProductDefinitions on Tracking.fk_product = ProductDefinitions.id
where tracking.fk_datagroup = 1
and measures.fk_dataItem in (1649, 1650, 1651, 1652, 1735, 1736, 1737)
and measures.dt >= '21.03.2015' and Measures.dt < '22.03.2015') t0
INNER JOIN tabelle t1
ON t0.Datum = t1.Datum
AND t0.DMC = t1.DMC
AND t0.Produkt = t1.Produkt
AND t1.[Description] = 'DAC_Offset'
INNER JOIN tabelle t2
ON t0.Datum = t2.Datum
AND t0.DMC = t2.DMC
AND t0.Produkt = t2.Produkt
AND t2.[Description] = 'DAC_Gain'
INNER JOIN tabelle t3
ON t0.Datum = t3.Datum
AND t0.DMC = t3.DMC
AND t0.Produkt = t3.Produkt
AND t3.[Description] = 'DAC_Gain_max'
INNER JOIN tabelle t4
ON t0.Datum = t4.Datum
AND t0.DMC = t4.DMC
AND t0.Produkt = t4.Produkt
AND t4.[Description] = 'DAC_Gain_min'
LEFT JOIN tabelle t5
ON t0.Datum = t5.Datum
AND t0.DMC = t5.DMC
AND t0.Produkt = t5.Produkt
AND t5.[Description] = 'sng_Gain'
LEFT JOIN tabelle t6
ON t0.Datum = t6.Datum
AND t0.DMC = t6.DMC
AND t0.Produkt = t6.Produkt
AND t6.[Description] = 'sng_Gain_max'
where t0.[Description] = 'DAC_Offset'