sql - Compare all parameters excluding the one selected? -
i'm working in sql server 2008. i've created stored proc, passed multiple values temp table. here's sample code of how temp table being populated:
declare @ownerkey varchar(75) = '2,3,7,9,14,18,23,26,28' /* ***** temp table ***** */ if object_id('tempdb..#ownertable','u') not null drop table #ownertable create table #ownertable (owner varchar(10)) insert #ownertable select value ttt.parselist(@ownerkey,',') /* ***** temp table ***** */
later joined table, in order bring in multiple owner keys such:
select t.product, o.ownerid table t join #ownertable o on o.owner = t.owner
the issue i'm having stored proc being used in report , need exclude parameter being selected supposed compared other keys. question may convoluted, i'll best answer questions.
essentially if user chooses parameter 2 want compare results other keys excluding key number 2 , need in ssms. i've tried merge when not matched
, no avail. sorry long question, new sql.
you may want this:
select t.product ,o.ownerid table t left join #ownertable o on o.owner = t.owner o.ownerid null;
in way "exclude" records match.
Comments
Post a Comment