when a.name and a.rownum=1 <> b.name and (b.namereason isnull or b.namereason in ('') and b.rownum=1 then a.name
when when a.name and a.rownum=1 <> b.name and (b.namereason isnotnull or b.namereason not in ('')) and b.rownum=1 then b.name
END as name

Note: I want to compare 2 tables.

A.RowNum = is take the max date

B.rownum = is take min date

I want compare the name if got update in B, then display B else display A.

I'm dealing with 10m+ records, cannot hardcode it. I need it to be working for generally.

i got error when doing something like this. error message is An expression of non-boolean type specified in a context where a condition is expected

any idea how to do something like?

closed as unclear what you're asking by mustaccio, Colin 't Hart, Paul White Mar 7 at 14:12

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • when a.name and - you should write a condition for example when a.name = 'aaa' and ' ... – Sabin Bio Mar 7 at 10:19
  • @sabin im deal with 10m+ records. Maybe i could come out with a.name is/is not null. I will try it later. – user3542587 Mar 7 at 10:34
  • 1
    For a quick (and possible better) answer, you should supplies sample data, with desired output. – Sabin Bio Mar 7 at 10:37

1) The code (pseudo) you posted is so badly indented. Please fix it for readability, and you should see why the error might be arising.

a.rownum=1 <> b.name

2) Can you please explain in plain simple words and illustrate with examples?

Not the answer you're looking for? Browse other questions tagged or ask your own question.