Union of several queries

S

sverre

Hi

I have built a union query (still not complete with all 40 queries but 3 are
built and shown below) that looks like this:

SELECT * FROM [ÄÄ Saldo 2741 summerad]
UNION
SELECT * FROM [ÄÄ Saldo 2751 endast nollkupongare summerad]
UNION
SELECT * FROM [ÄÄ Saldo 2751 exkl nollkupongare summerad];

The second and third query above should if possible be shown on same row,
"summed" (fields to be summed are named "SESAM"; HB. The last field
"account" is only for information and is for these queries the same number,
"2751" and should NOT be summed)

Secondly it this not is possible then I would like to add a comment-field to
be shown with the value "Zerobond" and "nonzerobond" for respective 2 queries
above.

Many thanks in advance,

Sverre
 
K

KARL DEWEY

The second and third query above should if possible be shown on same row
A union query does not put data on the same row.
A union query does not sum data.
Any comments would need to be either written into the union query or be a
prompt for when the query is run.

A union query does nothing more than appending queries together. Fields
must be the same type and the number of fields must mact or be padded.
The SQL for padding would look like this --
SELECT Field1, Field2, Field3
FROM TableA
UNION SELECT Field1, Field2, Null
FROM TableB
UNION SELECT Field5 AS Field1, Field6 AS Field2, NULL
FROM TableA

--
KARL DEWEY
Build a little - Test a little


sverre said:
Hi

I have built a union query (still not complete with all 40 queries but 3 are
built and shown below) that looks like this:

SELECT * FROM [ÄÄ Saldo 2741 summerad]
UNION
SELECT * FROM [ÄÄ Saldo 2751 endast nollkupongare summerad]
UNION
SELECT * FROM [ÄÄ Saldo 2751 exkl nollkupongare summerad];

The second and third query above should if possible be shown on same row,
"summed" (fields to be summed are named "SESAM"; HB. The last field
"account" is only for information and is for these queries the same number,
"2751" and should NOT be summed)

Secondly it this not is possible then I would like to add a comment-field to
be shown with the value "Zerobond" and "nonzerobond" for respective 2 queries
above.

Many thanks in advance,

Sverre
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top