Re: Help Finding records with matching columns

From: Vishal Parkar (REMOVE_THIS_vgparkar_at_yahoo.co.in)
Date: 08/20/04

  • Next message: Nilesh Barbhaya: "anyone can give solution for this problem"
    Date: Sat, 21 Aug 2004 04:21:45 +0530
    
    

    if i understand your requirement correctly you can try the query given in
    following example.

    --sample data
    create table t(col1 char(1),col2 char(1),col3 char(1),col4 char(1),col5
    int,col6 int)
    go
    insert into t
    select 'A','B','C','e',97, 2 union all --row will be updated
    select 'A','B','C','e',9, 3 union all
    select 'A','B','C','e',95, 2 union all
    select 'A','B','C','e',97, null union all
    select 'A','B','C','e',97, 5 union all --row will be updated
    select 'A','B','C','x',9, 3 union all
    select 'A','B','C','x',95, 2
    go
    --query
    update t set col6 = null
    where exists
    (select col1,col2,col3,col4
    from t x
    where t.col1 = x.col1 and t.col2 = x.col2 and t.col3=x.col3 and t.col4 =
    x.col4
    group by col1,col2,col3,col4
    having count(*) > 1)
    and t.col5 = 97 and t.col6 is not null

    -- 
    Vishal Parkar
    vgparkar@yahoo.co.in | vgparkar@hotmail.com
    

  • Next message: Nilesh Barbhaya: "anyone can give solution for this problem"

    Relevant Pages

    • (long) An AES implementation for 32-bit platforms
      ... union BLOCK ... needed in the AES algorithm. ... typedef unsigned int word; ... void computetables() ...
      (sci.crypt)
    • Re: Unions Redux
      ... union {int s; unsigned int us;} u; ... depends on the object representation compatibility, ... all to do with the fact that there is a union involved. ... is a trap representation for signed int. ...
      (comp.lang.c)
    • Re: Nesting dis-similar hierarchies
      ... create table Teams(TeamIndex int, ReqTeamName varchar(5), TeamNumber int) ... UNION ... TeamIndex, ReqTeamName, TeamNumber, ...
      (microsoft.public.sqlserver.xml)
    • Re: Hierarchy
      ... The query is below, and I encourage you to study it closely to see what ... The keystr that appears in the query is a simplifcation that I could ... CREATE TABLE h (col1 int NOT NULL, ... SELECT 2 UNION ...
      (comp.databases.ms-sqlserver)
    • Re: void * pointer convert problem.
      ... >> int year; ... unions: if a union contains several structures that share a common ... _common initial sequence_ if corresponding members have compatible ...
      (comp.lang.c)