sql - How to select most recent values? -


I have a logging table to store with several checks:

  create table [Log] Int IDENTITY (1, 1) No Taps, [minutes] datetime not null, [ProbeID] int 0 minus, [value] float (24) zero zero default 0.0, contract log_PK primary key [LogID]) [Normally, each probe generates a value every minute] [Log in] ([minute], [ProbeID], [value])  

Some examples output:

  log ID minutes probed mother N ====== =============================== 873875 2014-07-27 09:36 1972 24.4 873876 2014-07 -27 09:36 2001 29.7 873877 2014-07-27 09:36 3781 19.8 873878 2014-07-27 09:36 1963 25.6 873879 2014-07-27 09:36 2002 22.9 873880 2014-07-27 09:36 1959 -30.1 873881 2014-07-27 09:36 2005 20.7 873882 2014-07-27 09:36 1234 23.8 873883 2014-07-27 09:36 1970 19.9 873884 2014-07-27 09:36 1991 22.4 873885 2014-07 -27 09:37 1958 1.7 873886 2014-07-27 09:37 1962 21.3 873887 2014-07-27 09:37 1020 23.1 873888 2014-07 -27 09:38 1972 24.1 873889 2014-07-27 09:38 3781 20.1 873890 2014-07-27 09:38 2001 30 873891 2014-07-27 09:38 2002 23.4 873892 2014-07-27 09:38 1963 26 873893 2014-07-27 09:38 2005 20.8 873894 2014-07- 27 09:38 1234 23.7 873895 2014-07-27 09:38 1970-19.8 873896 2014-07-27 09:38 1991 22.7 873897 2014-07- 27 09:39 195 8 1.4 873898 2014-07-27 09:39 1962 22.1 873899 2014-07-27 09:39 1020 23.1  

The latest readings for each investigation C What is the most efficient way to achieve?

For example the product (note: "value" is not maximum () or an average ()):

  log id min probid value ===== ============================== 873899 27-Jul-2014 09:39 1020 3.1 873894 27-Jul-09 09:38 1234 23.7 873897 27-July-2014 09:39 1958 1.4 873880 27-Jul-09 09: 36 1959-30.1 8738 9 27-July-2015 09:39 1962 22.1 8738 9 27-July-2014 09:38 1963 26 8738 9 27-July-2014 09:38 1970 19.8 873888 27-July-2015 09:38 1972 24.1 873896 27-Jul-2014 09:38 1991 22.7 873890 27-Jul-2014 09:38 2001 30 873891 27- July-2014 09:38 2002 23.4 873893 27-Jul-2014 09:38 2005 20.8 873889 27-Jul-2014 09:38 3881 20.1.  

This is another way Select from Log L * * where minute = (Select Max X (Ext.) From Log X where x.probeid = l.probeid) < P> You can compare performance plan w / a bela -


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -