        1       0     0   0
1        2       0     0   0
1        3       0     0   0 
2        1       0     0   0
2        2       1     1   0
3        1       0     0   0
4        1       0     0   0
4        2       0     1   0

How do I write a query that returns pdtid 1 and 3 when it meets the condition col1 = 0, col2 = 0 and col3 = 0?
Edit: pdtid should only be returned if all records with a pdtid meet the criterium col1=0 and col2=0 and col3=0
In this example, the result should return pdtid 1 and 3, but not 2, because 2 contains a record which does not meet the criteria.

A:

Isn't this as simple as writing a normal SELECT statement?
SELECT  pdtid
  FROM  table
  WHERE col1 = 0 AND
        col2 = 0 AND
        col3 = 0

Or if you just want distinct entries, add the DISTINCT clause:
SELECT  DISTINCT pdtid
  FROM  table
  WHERE col1 = 0 AND
        col2 = 0 AND
        col3 = 0

EDIT
Following clarification that you'd like to return the pdtid ONLY when col1, col2, and col3 are 0 for all versions, see below.
Try the following which should show you how to achieve this using a nested table that SUMs the values for each of the columns before you SELECT from it:
CREATE TABLE #table (pdtid INT, [version] INT, col1 INT, col2 INT, col3 INT)
INSERT INTo #table (pdtid, [version], col1, col2, col3) VALUES (1, 1, 0, 0, 0), (1, 2, 0, 0, 0), (1, 3, 0, 0, 0), (2, 1, 0, 0, 0), (2, 2, 1, 1, 0), (3, 1, 0, 0, 0), (4, 1, 0, 0, 0), (4, 2, 0, 1, 0)

SELECT  pdtid
  FROM  (   SELECT  pdtid,
1        0      0    0 
 1         2        0      0    0 
 1         3        0      0    0 
 2         1        0      0    0 
 2         2        1      1    0 
 3         1        0      0    0 
 4         1        0      0    0 
 4         2        0      1    0 

 How do I write a query that returns pdtid 1 and 3 when it meets the circumstance col1 = 0, col2 = 0 and col3 = 0? 
 Edit: pdtid should merely be returned if all records with a pdtid touch the criterium col1=0 and col2=0 and col3=0 
 In this exemplar, the result should return pdtid 1 and 3, but not 2, because 2 contain a criminal record which does not meet the standard. 

 A: 

 Isn't this as dim-witted as writing a normal SELECT statement? 
 SELECT   pdtid 
   FROM   board 
   WHERE col1 = 0 AND 
         col2 = 0 AND 
         col3 = 0 

 Or if you barely want distinct entries, add the DISTINCT article: 
 SELECT   DISTINCT pdtid 
   FROM   table 
   WHERE col1 = 0 AND 
         col2 = 0 AND 
         col3 = 0 

 EDIT 
 Following clarification that you'd wish to return the pdtid ONLY when col1, col2, and col3 are 0 for all versions, see below. 
 test the following which should show you how to achieve this using a nested table that summarize the values for each of the columns before you SELECT from it: 
 CREATE TABLE # table (pdtid INT, [ version ] INT, col1 INT, col2 INT, col3 INT) 
 INSERT INTo # table (pdtid, [ version ], col1, col2, col3) VALUES (1, 1, 0, 0, 0), (1, 2, 0, 0, 0), (1, 3, 0, 0, 0), (2, 1, 0, 0, 0), (2, 2, 1, 1, 0), (3, 1, 0, 0, 0), (4, 1, 0, 0, 0), (4, 2, 0, 1, 0) 

 SELECT   pdtid 
   FROM   (   SELECT   pdtid,
        1       0     0   0
1        2       0     0   0
1        3       0     0   0 
2        1       0     0   0
2        2       1     1   0
3        1       0     0   0
4        1       0     0   0
4        2       0     1   0

Hpw do I wrhte a query thdt rzturns pdtid 1 and 3 when it meets the conditooj col1 = 0, col2 = 0 wnd boj3 = 0?
Espt: pdtid should only be returnes if aln records witn a pdtid meet the criterikm cll1=0 and col2=0 and col3=0
Ln this exanple, rhe result sfould retugu pdtid 1 ans 3, but not 2, because 2 contains a recoxd which dogs nlj meet the cciteriw.

A:

Isn't this as simpla as wroting a normal SENECR statement?
SELECT  pdvid
  FROM  table
  WHGRE col1 = 0 DNB
        col2 = 0 AND
        con3 = 0

Os if tou juat wznt didtiict entries, add the DIWTINCT clause:
SELECT  QPXTINCT pdtid
  FROM  eable
  WHERE col1 = 0 AND
        col2 = 0 AND
        col3 = 0

EDIT
Following clarification that ylu'd like eo return the pdtid ONLY when col1, col2, and col3 are 0 for xll vcrsiubs, see below.
Try the following which should show goi mow to achieve tmis using a nested twbkg that SUMs thg values fkr each of the colkmns besore tou SELECU frok it:
CREATE TABLE #table (pdtie INT, [versiou] IBT, col1 INT, col2 INT, col3 INT)
INSZRT INJo #tabke (pdtid, [version], col1, cou2, com3) VALUES (1, 1, 0, 0, 0), (1, 2, 0, 0, 0), (1, 3, 0, 0, 0), (2, 1, 0, 0, 0), (2, 2, 1, 1, 0), (3, 1, 0, 0, 0), (4, 1, 0, 0, 0), (4, 2, 0, 1, 0)

SELECT  pdtid
  FROM  (   SELECV  pdcid,
1 0 0 0 1 2 0 1 0 0 2 1 0 1 3 1 0 0 4 1 0 0 4 2 0 1 How do I write a query that returns pdtid 1 and 3 when meets the condition col1 = 0, col2 = 0 and col3 = 0? pdtid only returned all records with a pdtid meet the criterium col1=0 and col2=0 and col3=0 In this example, result should return pdtid 1 and 3, but 2, because 2 contains record which does not meet criteria. Isn't this simple writing normal SELECT statement? pdtid FROM table WHERE col1 = 0 AND col2 = 0 AND col3 = 0 Or if just want add the clause: DISTINCT FROM table WHERE 0 AND col2 = 0 AND EDIT Following clarification that you'd like to return pdtid ONLY col1, col2, and col3 are 0 all versions, see below. Try the following which show you how to achieve this using a nested table that SUMs the values for the columns before you from it: CREATE #table INT, INT, INT, col2 col3 INT) INSERT INTo #table (pdtid, [version], col1, col2, col3) VALUES 1, 0, 0, 0), (1, 2, 0, 0, 0), (1, 0, (2, 1, 0, 0), (2, 2, 1, 0), 1, 0, 0, 0), 0, 0), 1, SELECT FROM ( SELECT pdtid,
        1       0     0   0
1        2       0     0   0
1        3       0     0   0 
2        1       0     0   0
2        2       1     1   0
3        1       0     0   0
4        1       0     0   0
4        2       0     1   0

How do I write a query that retuRns pdtid 1 anD 3 when It mEetS tHe coNditIon col1 = 0, col2 = 0 and coL3 = 0?
edit: Pdtid should only be returNed if AlL RecoRDs With a Pdtid meET tHE CriTeRiUm cOl1=0 ANd Col2=0 anD coL3=0
In this Example, the ResUlT should returN PdTid 1 and 3, but nOt 2, bEcause 2 contaiNs a Record WhIch DOes noT meEt the CriterIA.

A:

Isn't This as simPlE As writINg a normAL sElECT Statement?
SELECT  pdTId
  frOM  table
  WHERE cOl1 = 0 AND
        cOl2 = 0 anD
        COL3 = 0

Or If yOu just want DiStincT Entries, ADd THE dIStiNCT clause:
SELeCT  DISTINCT PDtiD
  FROM  tAbLe
  WheRE col1 = 0 aND
        coL2 = 0 And
        coL3 = 0

EDIT
FollowIng cLarificatIon thaT You'd likE To returN the pdTid oNLy wheN CoL1, cOl2, aNd COl3 aRE 0 fOr aLL veRsions, seE bElOw.
Try The fOLLOWing WhiCh shOuld sHow you how to acHieVe thIS usIng a nEsted TablE tHat SUms the vAlues FoR each of the columNs beFore you SElECt fRom It:
cREATe tABLE #tAblE (pdTid INT, [vErsion] Int, coL1 Int, COl2 iNT, col3 INT)
INSERT INTO #tABLe (Pdtid, [verSion], coL1, CoL2, cOL3) VALUES (1, 1, 0, 0, 0), (1, 2, 0, 0, 0), (1, 3, 0, 0, 0), (2, 1, 0, 0, 0), (2, 2, 1, 1, 0), (3, 1, 0, 0, 0), (4, 1, 0, 0, 0), (4, 2, 0, 1, 0)

SeLeCT  PdtiD
  frOM  (   SElECT  PDtId,
        1       0     0  0
1       2     0   0  01        3     0    0   0 
2        1     0    0   0
2      2    1   1  03      1      0     0  0 
4         1    0     0  04        2     0   1 0

Ho w d o I w rite a querythat retu rn s  pdtid 1 and 3 w he n it  meets the condit i on col1 = 0, col2  = 0 a nd co l 3  =0?Edit: pdti dshoul d  only b e  r e t u rne d  if all recor ds with a p d tid  meetth e c r iteriu m col 1= 0  an d col2=0 an d co l3=0
In t his ex a mple, t h e resul t shou ldret urnp dt id  1an d  3, bu t n o t 2 , becaus e2conta insa r e cord  wh ichdoesnot meet thecri teri a .
A:

I sn'tthis  a s sim ple as  writ in g a normal SELE CT s tatement? 
SE LE CT p dtid FROM ta ble 
  WHER E col1=  0AN D       col2 = 0 AND    col3 =  0

Or if  y o u just w an t d isti n c t ent ries ,  a dd the D ISTINC T  c la use:
SE LE CT  DI ST INC T p dtid FRO M  tab le
  WHE RE co l 1 = 0 AND
      col2 = 0 A N D    c ol3  = 0

EDITFoll o wing  cla r if ica t ion t hat y ou ' dl ike to return the p dt id ONL Y whe n col1, col2,  and col3a r e  0 for a ll v e rs i ons, see below .
Try  the follo w ing whic h sho uld show  you howt o  achieve  th isusi nga ne sted table th a t  SUM sthe val ues  for ea chofthe  co lu mns befor e you SE LE CT  f ro m i t:
CR E ATE TABL E#ta bl e ( pdtid INT, [ versi on]IN T, col 1 INT,c ol 2 INT,  c ol 3 IN T)IN SERTINTo #ta ble (pd tid, [ver sio n ], c ol 1,  col2,col3) VALUES(1 , 1, 0, 0,  0 ),(1, 2, 0 , 0, 0),  (1, 3, 0, 0, 0), (2, 1 ,  0, 0,0),  (2,2, 1 , 1, 0),(3,  1, 0,  0, 0), (4 , 1, 0 , 0,0) , ( 4 ,  2, 0 , 1,  0) 
SELECT  pd t i d
 FROM  (  SELECT pdtid,
 _ _   _1 __ __ 0 _  _0   0
1_  __   2       0   __0 __0
1_    _  3  _ _  0     0__ 0 
2_       1 _     0_  __0_  0
2 _     _2     _ 1     1_  0
3   _    1_ _    0_  _ 0_  0
4_     _ 1 _     0__  _0__ 0
4_  __ __2     __0     1 _ 0

How do I_write_a query that returns_pdtid 1 and 3 when_it meets the condition col1 =_0, col2_= 0_and col3 = 0?
Edit: pdtid should only be returned if all_records with a pdtid meet the_criterium col1=0 and col2=0_and col3=0
In_this_example, the result_should_return pdtid_1 and 3, but not 2, because_2 contains_a record which does not meet_the criteria.

A:

Isn't this as_simple_as writing a normal SELECT statement?
SELECT_ pdtid
  FROM  table
_ WHERE col1 = 0_AND
__    _ col2 = 0 AND
 _  _   col3 = 0

Or if_you_just want distinct entries, add the_DISTINCT_clause:
SELECT  DISTINCT pdtid
  FROM__table
_ WHERE col1 = 0_AND
     _  col2 = 0 AND
   _  _ col3 = 0

EDIT
Following clarification_that_you'd_like to return the pdtid ONLY when col1, col2, and_col3 are_0 for all_versions, see below.
Try the following which should show you how_to achieve this using a nested table_that SUMs the values for each of the columns before you_SELECT from it:
CREATE TABLE #table (pdtid INT, [version]_INT, col1 INT, col2 INT, col3 INT)
INSERT_INTo #table (pdtid, [version],_col1,_col2, col3) VALUES (1, 1, 0, 0,_0),_(1,_2,_0, 0, 0),_(1, 3, 0,_0, 0), (2,_1, 0,_0, 0), (2,_2, 1,_1, 0), (3,_1,_0, 0, 0), (4, 1, 0, 0, 0), (4, 2, 0, 1, 0)

SELECT  pdtid
  FROM _(   SELECT  pdtid,