create table #t (maker varchar(100), model varchar(100...


Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

create table #t (maker varchar(100),   model  varchar(100), type varchar(100) );
insert into #t ( maker,   model,   type )  values 
( 'B',   '1121',    'pc'),
( 'A',   '1233',    'pc'),
( 'E',   '1260',    'pc');

totals as (
   select maker, type,
       count( * ) as n
   group by 
      maker,  type
      ) ,
maker_type as (
   select distinct maker, type
   from #t
   mm.*, t.n, 
   case  when t.n is null then 'No' else 'Yes' end as yes_no
   maker_type mm
left outer join
   totals t
      on mm.maker = t.maker and
         mm.type = t.type

Enter Parameters

Switch sites:
loading Hold tight while we fetch your results
:records returned in :time ms:cached