Many thanks for that :-)
Its nearlly working. I found a Problem and I dont't know what's happend there.
In "othetable" the date column is datatype Datetime. In the first part of the select Statement will be done a cast to date which is fine. When I try to Cast also the date column in the second table to "Date" it gives me no data as result. When i use as dataype "date" in the Column date (Othertable)it Woks fine.
I use follwing Statement at the Moment.
select m.*,m.Diff/n.Mat_Weight AS Consumption,n.Mat_Date
, cast(Eventdate as date) as [Date]
, MAX (convert (decimal(20,2),Value)/10) - MIN(convert (decimal (20,2),Value)/10) AS Diff
from [TestDB].[dbo].[v_RAW] as p
where CounterID = 2
group by CounterID
, cast(Eventdate as date)
inner JOIN Material n
ON n.CounterID = m.CounterID
and cast (n.[Mat_Date] as date) = m.[Date]
The second Problem is, how can i divide (1000) "n.Mat_Weight" direct in the first part? Or should it be done later in the Statement?
Many thanks for your help !!