• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

SQL with union all

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SQL with union all

    Hello,

    I am trying to use NAB to create statistics for one customer and I have a complicated SQL that I can't get to work.
    Single parts are processed but as soon as I use UNION ALL I get the error:

    Compound/union statement columns must all have the same identifier."

    I then tried a simple example with the democmast and also here I get the same error as soon as the SELECT Columns are different.

    Code:
    select cusno, cname from democmast
    union all
    select cname, czip from democmast
    maybe someone has an idea or solution


  • #2
    Hi David,

    I think you just need to ensure the column names in each of the successive UNION clauses are identical for the NAB SQL logic. So insert an alias ("AS xxxx") wherever necessary to ensure all the column names match, i.e...

    Code:
    select cusno, cname as name, caddr1 as addr from democmast
    union all
    select cusno, ccountry as name, caddr2 as addr from democmast

    Comment

    Working...
    X