Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello guys, quick question I have this set of data that repeats when ever a case change status, let's say we have assigned, unassigned, work in progress, closed, etc. I need to remove the instances of when a case is changed to closed, not downloading any data when the query is executed.

here is an example of a case:

type       caseid   businesssource      status
dummytype    921ed59f   dummy            CLOSED
dummytype    921ed59f   dummy            CLOSED
dummytype    921ed59f       dummy            UNASSIGNED
dummytype    921ed59f   dummy            UNASSIGNED


Hence in this case I need this data to be completed deleted as it's already a closed case.

What I have tried:

Here is an example of what I've been trying to do but with no success.

    select

     status
    , caseid
    , domain
    , marketplaceid
    , concat ('Q', datepart(quarter, creationdate)) as created_quarter
    , case when marketplaceid = 1 then 'US'
           when marketplaceid = 3124564 then 'GO'
           when marketplaceid = 5646897 then 'PUS'
           when marketplaceid = 3213165 then 'Te'
           when marketplaceid = 32132131 then 'FED'
           else 'LOV'
      end as marketplace
    , assignee
    , businesssource
    , queue
    , creationdate
    , closuredate
    , identifier 
    -- datefiff (day, closuredate, creationdate ) as SLA
    , ROW_NUMBER() OVER (PARTITION BY caseid, queue, identifier order by status asc) as rnk

    from dummytable

    where status in ('WORK_IN_PROGRESS','ASSIGNED','UNASSIGNED','PENDING_VENDORSELLER_COMMUNICATION')
    and trunc(creationdate) between '2019-01-01' and sysdate
    and domain not in ('Demo')
Posted
Updated 27-Aug-19 4:13am
v2

1 solution

Use an UPDATE query:
SQL
UPDATE MyTable SET ColumnToChange=NewValue, OtherColumnToChange=OtherNewValue 
WHERE conditionToSelectRowsToChange

For more details: SQL UPDATE Statement[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900