1

I am newbie to teradata.

I need to delete a row once the case condition is satisfied.

Eg: case condition true delete the selected row.

Brian Tompsett - 汤莱恩
  • 5,195
  • 62
  • 50
  • 120
balaji
  • 9
  • 1
  • 1
  • 3
  • Can you expand a little more on what you are trying to accomplish that can't be done with a WHERE clause? – Rob Paller Jul 31 '12 at 17:11
  • case when col1=31 then (case when desc= 'xxxxxx' then delete the entire row end) else xxxx end – balaji Jul 31 '12 at 18:07

1 Answers1

0

Maybe I am misinterpreting what you are trying to accomplish with the CASE statement, but based on my understanding you can use the WHERE clause to conditionally remove data from a table:

DELETE
FROM MyDB.MyTable
WHERE Col1 = 31
  AND "Desc" = 'xxxxxx';

EDIT:

Based on your comment then you need to apply the CASE logic to each column returned in the SELECT statement that you wish to obscure.

SELECT CASE WHEN Col1 = 31 and "DESC" = 'yyyyy'
            THEN NULL
            ELSE ColA
       END AS ColA_,
    /* Repeat for each column you wish to "delete" */
  FROM MyDB.MyTable;
Rob Paller
  • 7,506
  • 23
  • 23
  • Hi Rob, Thanks for your quick response sel xx ,yy ,zz ,case when col1=30 then (case when desc ='yyyy' then aaaa end) when col1=31 then (case when desc= 'xxxxxx' then delete the entire row end) else xxxx end as ll from mytable I need to delete the row from which i am selecting – balaji Jul 31 '12 at 19:13