DB2 SQL Using a set of clauses from this years sales to find out what the Client purchased last year -


db2 sql using set of clauses getting result of specific deals.

now trying (using exists) @ same table , matching part_num, customer_name , date(date - 1 year) previous years sales same parts/cust.

my end result if give me previous years deals customer number , part match years sales. cannot seem work suspect there maybe easier way.

select part_num, customer_num,start_date, end_date  tablea salesnumber = )as  (exists         (  select part_num, customer_num,start_date, end_date table )as b  b.part_num = a.part_num , b.customer_num = a.customer_num , date(a.start_date) = year(b.start_date - 1 year) 

i sure have wrong. thoughts?

try (but please try make effort next time...):

select part_num     ,customer_num     ,start_date     ,end_date table     exists (             select part_num                 ,customer_num                 ,start_date                 ,end_date             table b              b.part_num = a.part_num             , b.customer_num = a.customer_num             , year(a.start_date) = year(b.start_date) - 1 ) 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -