Solved

DataReport simple question

Posted on 2002-05-31
4
131 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
Comment Utility
P.S.  The table was written using a Fixed font.
0
 
LVL 4

Expert Comment

by:gencross
Comment Utility
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
Comment Utility
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
Comment Utility
The answer was almost correct. Anyway, I understood the idea.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now