sql server - SQL: Match Set of Approximate values -
in info set there set of numeric values match equal sized set of values table "closest match" (without going on desired:
left right m b n c o d p
so goal bring together left right, giving m resulting row < m , m - minimum [m..p - a].
(ignore a..d , m..p might have more 1 element same value.)
edit: similarly, b needs match n, c o, , d p.
tables have multiple sets of such values, such e..g match q..s these in separate grouping on other fields not shown.
there might many of these "sets" of matches (based on other fields in table.
suggestions or ideas? preferable in t-sql or basic sql.
does want?
select l.*, (select max(r.right) right r r.right <= l.left ) rightmatch left l;
note: sketch of sql. left
, right
(obviously) reserved words. i'm using them match naming conventions in query. shouldn't utilize reserved words column or table names.
sql sql-server join approximate
No comments:
Post a Comment