From: Henrique on 12 Jul 2010 05:36 Hi I need help building a query. Hi have this table: Cunter day 09-07-2010 Reg_Numb DateTime value 1 09-07-2010 09:00 5000 2 09-07-2010 10:00 5010 3 09-07-2010 11:00 5050 4 09-07-2010 12:00 5100 5 09-07-2010 13:00 5150 6 09-07-2010 14:00 5200 7 09-07-2010 15:00 5230 8 09-07-2010 16:00 5300 9 09-07-2010 17:00 5305 10 09-07-2010 18:00 5400 Sometimes there are multiple records with the same time but with different minutes. I want this table as a result hours result 09 10 10 40 11 50 12 50 12 50 14 30 15 70 16 5 17 95 18 Thanks Seabra
From: pers on 12 Jul 2010 05:57 select substring( convert(varchar(10), p.DateTime,8),1,2) as hours, (value - (select min(value) from table1 as t where t.Reg_Numb>p.Reg_Numb) ) as Result from table1 as p "Henrique" <Henrique(a)discussions.microsoft.com> wrote in message news:C50493D7-B63A-493A-A054-768E51C1019C(a)microsoft.com... > Hi > > I need help building a query. > > Hi have this table: > > Cunter day 09-07-2010 > > > Reg_Numb DateTime value > 1 09-07-2010 09:00 5000 > 2 09-07-2010 10:00 5010 > 3 09-07-2010 11:00 5050 > 4 09-07-2010 12:00 5100 > 5 09-07-2010 13:00 5150 > 6 09-07-2010 14:00 5200 > 7 09-07-2010 15:00 5230 > 8 09-07-2010 16:00 5300 > 9 09-07-2010 17:00 5305 > 10 09-07-2010 18:00 5400 > > Sometimes there are multiple records with the same time but with different > minutes. > > I want this table as a result > > hours result > 09 10 > 10 40 > 11 50 > 12 50 > 12 50 > 14 30 > 15 70 > 16 5 > 17 95 > 18 > > > Thanks > Seabra >
|
Pages: 1 Prev: SqlTransaction Problem Next: Help about numeric type field. Thanks. |