473,387 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to split one data field into 3 and count number of rows in each?

I am working in Access 2002 and trying to create a report from our company's learming management system. I am not a DBA and most of my SQL knowledge has been self taught through trial and error. I have created an access query to track the number of training hours for a training group. The query is working except for one piece of data and I hoping someone can help me. There is a field titled enrollment status, which presents an alpha character of C, E or N, all in one column. I would like to present this information in 3 columns (one for each status code) as a count vs the actual data. I have sucessfully created the 3 columns and am able to get a count of one of the values. However, I end up with the same count in each column. My query includes multiple "union all" statements as wells because I have multiple course categories that I need to combine into one report. Here is the code for the first group.

SELECT I.LEARNINGACTIVITYTITLE, I.LEARNINGACTIVITYCODE, I.CODE, I.STARTDATE, I.ENDDATE, I.UNITS, I.ENROLLEDCOUNT, COUNT (T.ENROLLMENTSTATUS) AS COMPLETED, COUNT ( T.ENROLLMENTSTATUS) AS ENROLLED, COUNT (T.ENROLLMENTSTATUS) AS SKIPPED
FROM LMS650_DRLAINSTANCEFULL AS I, LMS650_DRLATRANSCRIPTFULL AS T
WHERE T.LEARNINGACTIVITYID=I.LEARNINGACTIVITYID AND T.INSTANCECODE= I.CODE AND I.LEARNINGACTIVITYCODE LIKE 'ODE%' AND ((I.STARTDATE) Between #8/1/2006# And #8/31/2006#) AND T.ENROLLMENTSTATUS='C'
GROUP BY I.LEARNINGACTIVITYTITLE, I.LEARNINGACTIVITYCODE, I.CODE, I.STARTDATE, I.ENDDATE, I.UNITS, I.ENROLLEDCOUNT

UNION ALL SELECT I.LEARNINGACTIVITYTITLE, I.LEARNINGACTIVITYCODE, I.CODE, I.STARTDATE, I.ENDDATE, I.UNITS, I.ENROLLEDCOUNT, COUNT (T.ENROLLMENTSTATUS) AS COMPLETED, COUNT ( T.ENROLLMENTSTATUS) AS ENROLLED, COUNT (T.ENROLLMENTSTATUS) AS NO_SHOW
FROM LMS650_DRLAINSTANCEFULL AS I, LMS650_DRLATRANSCRIPTFULL AS T
WHERE T.LEARNINGACTIVITYID=I.LEARNINGACTIVITYID AND T.INSTANCECODE= I.CODE AND I.LEARNINGACTIVITYCODE LIKE 'ODE%' AND ((I.STARTDATE) Between #8/1/2006# And #8/31/2006#) AND T.ENROLLMENTSTATUS='E'
GROUP BY I.LEARNINGACTIVITYTITLE, I.LEARNINGACTIVITYCODE, I.CODE, I.STARTDATE, I.ENDDATE, I.UNITS, I.ENROLLEDCOUNT

UNION ALL SELECT I.LEARNINGACTIVITYTITLE, I.LEARNINGACTIVITYCODE, I.CODE, I.STARTDATE, I.ENDDATE, I.UNITS, I.ENROLLEDCOUNT, COUNT (T.ENROLLMENTSTATUS) AS COMPLETED, COUNT ( T.ENROLLMENTSTATUS) AS ENROLLED, COUNT (T.ENROLLMENTSTATUS) AS NO_SHOW
FROM LMS650_DRLAINSTANCEFULL AS I, LMS650_DRLATRANSCRIPTFULL AS T
WHERE T.LEARNINGACTIVITYID=I.LEARNINGACTIVITYID AND T.INSTANCECODE= I.CODE AND I.LEARNINGACTIVITYCODE LIKE 'ODE%' AND ((I.STARTDATE) Between #8/1/2006# And #8/31/2006#) AND T.ENROLLMENTSTATUS='N'
GROUP BY I.LEARNINGACTIVITYTITLE, I.LEARNINGACTIVITYCODE, I.CODE, I.STARTDATE, I.ENDDATE, I.UNITS, I.ENROLLEDCOUNT

ORDER BY I.LEARNINGACTIVITYCODE, I.CODE, I.LEARNINGACTIVITYTITLE, I.STARTDATE DESC;

As I indicated, the query is working correctly and pulling correct data except for the count. I am getting the correct count for the first select statement in the completed column, but the count for the completed column also appears in the enrolled column and the skipped column. I read something about counting horizontally vs vertically and tried a number of things including the case function, but have not been successful. We are on Windows 2002 professional. The DB is an oracle DB. I apologize if I am not presenting my question clearly, but this is my first post to a forum. Thank you.
Sep 18 '06 #1
1 4487
PEB
1,418 Expert 1GB
Hi,

it seems you want to use the count on different groups in one query doesn't it?

For every different grouping you need a different query!
Sep 19 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

19
by: David Logan | last post by:
We need an additional function in the String class. We need the ability to suppress empty fields, so that we can more effectively parse. Right now, multiple whitespace characters create multiple...
2
by: Dnna | last post by:
I have a table which is bound to an Internet Explorer XML data island. I'm using ASP.NET's client-side validators for an input field in the table. The problem is that if the input fields are in...
9
by: Brad | last post by:
I have written some code to manipulate data/records in a MASTER (order header) and DETAIL (order details) tables. What I have written is too extensive to post but essentially trying to: 1....
2
by: shapper | last post by:
Hello, I have the following code: 1 ' Code that creates the connection, parameters, etc 2 ' ... 3 4 ' Execute the command 5 6 ' ???? THE CODE I NEED TO KNOW
1
by: AMDRIT | last post by:
Occasionally I try my hand at a simple data storage engine. Today I ran across an article on the web http://msdn2.microsoft.com/en-us/library/aa289151(vs.71).aspx, and it got me thinking again. ...
6
Cintury
by: Cintury | last post by:
Hi all, I've developed a mobile application for windows mobile 5.0 that has been in use for a while (1 year and a couple of months). It was developed in visual studios 2005 with a back-end sql...
9
ADezii
by: ADezii | last post by:
One question which pops up frequently here at TheScripts is: 'How do I retrieve data from a Recordset once I've created it?' One very efficient, and not that often used approach, is the GetRows()...
3
ADezii
by: ADezii | last post by:
Last Tip, we demonstrated the technique for retrieving data from a DAO Recordset, and placing it into a 2-dimensional Array using the GetRows() Method. This week, we will cover the same exact Method...
0
by: wed1 | last post by:
Hi all I was asked from the company i support their intranet with asp to create a vb prog in order to retrive magazine circulations from their oracle server and update the number of circulations...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.