0

So trying to update an empty column that I just created with the script below. Whenever I try to run it I get the following error message (Query 1):

ORA-00933: SQL command not properly ended

So I googled around a bit and tried using a slightly different query (Query 2) but then get the following error message:

ORA-00904: "T1"."PLAYED_PREVIOUS_YEAR": invalid identifier

Anyone know why this might be?

Query 1:

update JWxsellallprod t1
   set t1.played_previous_year = case when t2.cust_id IS NOT NULL then 1 else 0 end
 from JWxsellallprod t1
 left join (select a.Year_of_Play,
                   a.Year_Aquired,
                   a.cust_id
              from JWxsellallprod a
             inner join JWxsellallprod b
                on b.cust_id = a.cust_id
             where a.player_days > 0
               and b.player_days > 0
               and b.Year_of_Play = a.Year_of_Play - 1
               and a.Year_Aquired = b.Year_Aquired
           ) t2
   on t2.cust_id = t1.cust_id
  and t2.Year_of_Play = t1.Year_of_Play
  and t2.Year_Acquired = t1.Year_Acquire;

Query 2

update JWxsellallprod t1
   set t1.played_previous_year
      = (select case when t2.cust_id IS NOT NULL then 1 else 0 end
           from JWxsellallprod t1
           left join (select a.Year_of_Play,
                             a.Year_Aquired,
                             a.cust_id
                        from JWxsellallprod a
                       inner join JWxsellallprod b
                          on b.cust_id = a.cust_id
                       where a.player_days > 0
                         and b.player_days > 0
                         and b.Year_of_Play = a.Year_of_Play - 1
                         and a.Year_Aquired = b.Year_Aquired
                     ) t2
             on t2.cust_id = t1.cust_id
            and t2.Year_of_Play = t1.Year_of_Play
            and t2.Year_Acquired = t1.Year_Acquire);
2

1 Answer 1

0

try this:

update JWxsellallprod a
set played_previous_year = (
  select sign(count(*))
  from JWxsellallprod b
  where a.player_days > 0 and b.player_days > 0
    and b.Year_of_Play = a.Year_of_Play - 1
    and a.Year_Aquired = b.Year_Aquired
    and a.cust_id = b.cust_id)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.