Solved

DataReport simple question

Posted on 2002-05-31
4
138 Views
Last Modified: 2010-05-02
Hello,

I have a table called Inst_kinds (Kind_code, Kind_name) and a table called Instruments (Inst_num, Kind_code, Status). The value of "Status" field (Integer) can be 1, 2, 3, 4 or 5. I want to get a report which will look like this:

         | Sta=1 | Sta=2 | Sta=3 | Sta=4 | Sta=5
   ------| ----- | ----- | ----- | ----- | -----
   Kind1 |   6   |   5   |   3   |   2   |   3
   Kind2 |   3   |   2   |   3   |   1   |   0
   Kind3 1   |   1   |   1   3   |   4   |   0
   Kind4 |   4   |   3   |   1   |   3   |   1
   Kind5 |   6   |   2   |   1   |   2   |   4
   ..... |  ...  |  ...  |  ...  |  ...  |  ...
   KindN |   X   |   Y   |   Z   |   P   |   Q

The data in the cells is:
Count(Inst_num) Where (Kind_code = 1) And (Stutus = 1)
Count(Inst_num) Where (Kind_code = 1) And (Stutus = 2)
Count(Inst_num) Where (Kind_code = 1) And (Stutus = 3)
Count(Inst_num) Where (Kind_code = 1) And (Stutus = 4)
Count(Inst_num) Where (Kind_code = 1) And (Stutus = 5)
Count(Inst_num) Where (Kind_code = 2) And (Stutus = 1)
Count(Inst_num) Where (Kind_code = 2) And (Stutus = 2)
etc, etc, etc, etc, etc, etc, etc, etc......

HOW CAN I DO THIS ???
0
Comment
Question by:slavikn
  • 2
  • 2
4 Comments
 
LVL 1

Author Comment

by:slavikn
ID: 7046725
P.S.  The table was written using a Fixed font.
0
 
LVL 4

Expert Comment

by:gencross
ID: 7046762
You can use GROUP BY.  Here is an example of the SQL you will want to use the return the records.

I'm writing this off of the top of my head so you may need to modify the SQL some, but you get the general idea.

sSQL = "select count(Inst_num) AS RecCount,Status,Kind_name,kind_code from Instruments INNER JOIN tbl on Instruments.Kind_Code = Inst_kinds.Kind_code GROUP BY Kind_name,kind_code,Status"

Hope this helps.
0
 
LVL 4

Accepted Solution

by:
gencross earned 50 total points
ID: 7046765
Oops!  Try this SQL...

sSQL = "select count(Inst_num) AS RecCount,Status,Kind_name,kind_code from Instruments INNER JOIN Inst_kinds on Instruments.Kind_Code = Inst_kinds.Kind_code GROUP BY Kind_name,kind_code,Status"
0
 
LVL 1

Author Comment

by:slavikn
ID: 7048520
The answer was almost correct. Anyway, I understood the idea.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question