[mailto:midrange-l-bounces@xxxxxxxxxxxx]On Behalf Of Joe Pluta
Sent: Thursday, March 13, 2008 3:57 PM
To: Midrange Systems Technical Discussion
Subject: Re: SQL Question - Merging files or result sets?
Bradley V. Stone wrote:
Alan,construct a single
I was wondering if using a union on two files if I can
count(*) SQL command to count the total records from both files.Brad, there are probably three or four ways to do what you're asking,
but it will help if you give a business reason. For example, I can get
you all the records from one file, followed by a row with the record
count, then all the records from the second file, followed by a count.
But remember that the result set must have the same columns in every
row, so you end up with an additional column for the file name (which
will be one of two values) and an addition column for the count (which
will be zero for every records EXCEPT the two total records).
You can also do two queries, one which gets you all the detail, and a
second which give you a single row with both counts (or two rows, each
with a count and a filename).
It really depends on what you're going to do with the data.
This is the Midrange Systems Technical Discussion (MIDRANGE-L)
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives