You can do this using aggregates and case statements (assuming your db can
handle it... you didn't say what you were using)


select checkno, total=count(*),
    -- I have no idea how you determine what is "unprocessed", so this is an
made-up example
    unprocessed=sum(case when is_processed<>'Y' then 1 else 0 end),
    -- repeat for other counts
    ....
from thetable
group by checkno


The idea is that you have a case statement that yields 1 or 0 depending on
the particular state you want to count and use sum() to count them.


    Mark

-----Original Message-----
From: Andre Turrettini [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 30, 2003 12:42 PM
To: CF-Talk
Subject: sql difficulty

Hi,
I'm wondering if there is a difffernet way to do this.

Basically I have a table that has lots of records.  I need to show in a list
multiple agregates on this table.  It pretty much has to be live to reflect
the current data.  One of the fields is a checkno.  This is main group.  So
everything groups on this. So I might have 10 with check no a, 20 with check
no b and 30 with check no c.  The list that the user sees would then have 3
entries.  There is additinal information in the table that I need to
agregate.  I need counts on other fields in that group where the other field
is this or that and sums on another field where that other field is that or
this.  So basically, it will look like this.

checkno | total | unprocessed | success | failure | sum | preped | unprepped
a            10                     7            2         1      65
3           4
B            20                     7            2         2      44
2          5
C            1                      7            2         3      28
4           3

So, should I simply run 5 agregate queries and mix the results into one
query result set?  Or is there another way?

Thanks in advance

DRE

[Andre Turrettini]  -----Original Message-----
From: Chunshen Li [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 30, 2003 8:23 AM
To: CF-Talk
Subject: UniData ODBC connectivity

Hi,

I've posted a similar question some time ago about UniData ODBC
connectivity.  This time, it's more specific.

I'm new to UniData.  I'd like to set up an ODBC connection to the UniData
database hosted on an NT box on the network.  I read some documentation.  Is
the following understanding correct?  Two key pieces: 1) uci.conf file, an
entry pointing to the train(training) database; 2) install Unidata ODBC
driver, making the ODBC datasource setup matches that.  

UniData questions (not ODBC), after login to Unidata, a) how to find the
current database, most likely default to production (Main), then, how to
switch to Train database? b) how to find what accounts are
available/associated with Train database? c) how to create an account for
Train database?

ODBC connection questions:
when using VSG to map schema, one has to call UniData file/data to do table
mapping, one file name is called IM (for Item Master), how to find all other
file names?  Of which, what would seem to be more important?

Many thanks.

Don Li
  _____  

  _____  


[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to