473,396 Members | 2,011 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,396 software developers and data experts.

Counting In a database

Ali Rizwan
925 512MB
Hi,
I have a database in which a field describes the attendance status of a teacher.
T for late, P for present, A for absent.
I want to calculate the number of Ts Ps and As.
How can i do this.
Using ADODC and vb6 and Access.
Thanx
Oct 1 '07 #1
8 1873
Killer42
8,435 Expert 8TB
Hi,
I have a database in which a field describes the attendance status of a teacher.
T for late, P for present, A for absent.
I want to calculate the number of Ts Ps and As.
How can i do this.
Using ADODC and vb6 and Access.
Just run a query that uses the Count() function. The easy way to set up queries like this is to create them in the GUI query designer in MS Access, then go to the SQL view and copy the SQL.
Oct 1 '07 #2
jrtox
89
Hi,
I have a database in which a field describes the attendance status of a teacher.
T for late, P for present, A for absent.
I want to calculate the number of Ts Ps and As.
How can i do this.
Using ADODC and vb6 and Access.
Thanx
Hello, A post reply of killer42 is Very good and simple but if you want a long one
Heres my Step.

dim HoldLate' Holds the number of Late.
dim HoldPresent' Holds the number of Present
dim HoldAbsent' Holds the number of Absent.


'Count the Number Of Late.
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "SELECT * FROM TableTeacher WHERE attendance_status='T' "
adodc1.refresh
HoldLate=adodc1.Recordset.RecordCount
'Count the Number Of Present.
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "SELECT * FROM TableTeacher WHERE attendance_status='P' "
adodc1.refresh
HoldPresent=adodc1.Recordset.RecordCount
'Count the Number Of Absent.
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "SELECT * FROM TableTeacher WHERE attendance_status='A' "
adodc1.refresh
HoldAbsent=adodc1.Recordset.RecordCount
Regards
Ervin
Oct 1 '07 #3
QVeen72
1,445 Expert 1GB
Hi,
I have a database in which a field describes the attendance status of a teacher.
T for late, P for present, A for absent.
I want to calculate the number of Ts Ps and As.
How can i do this.
Using ADODC and vb6 and Access.
Thanx
Hi,

One SQL Statement will do:
For single Teacher:
Expand|Select|Wrap|Line Numbers
  1. "SELECT Att_Status,Count(*)  FROM TableTeacher WHERE TeacherName = '" & Trim(txtName.Text) & "' Group By Att_Status"
  2.  
For All teachers:
Expand|Select|Wrap|Line Numbers
  1. "SELECT TeacherName, Att_Status,Count(*)  FROM TableTeacher  '" _
  2. & "' Group By TeacherName, Att_Status"
  3.  
REgards
Veena
Oct 1 '07 #4
Ali Rizwan
925 512MB
Hi,
Thanks a lot all.
But actually i have not ever used sql statements or quries.
So can you please made a demonstration/example for me.
I want it urgent.
Please help me
Thanx
Oct 1 '07 #5
Ali Rizwan
925 512MB
Hello, A post reply of killer42 is Very good and simple but if you want a long one
Heres my Step.

dim HoldLate' Holds the number of Late.
dim HoldPresent' Holds the number of Present
dim HoldAbsent' Holds the number of Absent.


'Count the Number Of Late.
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "SELECT * FROM TableTeacher WHERE attendance_status='T' "
adodc1.refresh
HoldLate=adodc1.Recordset.RecordCount
'Count the Number Of Present.
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "SELECT * FROM TableTeacher WHERE attendance_status='P' "
adodc1.refresh
HoldPresent=adodc1.Recordset.RecordCount
'Count the Number Of Absent.
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "SELECT * FROM TableTeacher WHERE attendance_status='A' "
adodc1.refresh
HoldAbsent=adodc1.Recordset.RecordCount
Regards
Ervin
Hello,
Thanks a loooooooooooooooooooot.
Its working.
Thanks again.
Oct 1 '07 #6
Ali Rizwan
925 512MB
Hello, A post reply of killer42 is Very good and simple but if you want a long one
Heres my Step.

dim HoldLate' Holds the number of Late.
dim HoldPresent' Holds the number of Present
dim HoldAbsent' Holds the number of Absent.


'Count the Number Of Late.
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "SELECT * FROM TableTeacher WHERE attendance_status='T' "
adodc1.refresh
HoldLate=adodc1.Recordset.RecordCount
'Count the Number Of Present.
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "SELECT * FROM TableTeacher WHERE attendance_status='P' "
adodc1.refresh
HoldPresent=adodc1.Recordset.RecordCount
'Count the Number Of Absent.
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "SELECT * FROM TableTeacher WHERE attendance_status='A' "
adodc1.refresh
HoldAbsent=adodc1.Recordset.RecordCount
Regards
Ervin
Hello,
Thanks a loooooooooooooooooooot.
Its working.
Thanks again.
I m also using another command for counting but some time it count a wrong number.
Ok can you please answer me this question
How can i sum up all the amount in Pay column?
Thanx again.
Oct 1 '07 #7
Ali Rizwan
925 512MB
Hello,
Thanks a loooooooooooooooooooot.
Its working.
Thanks again.
I m also using another command for counting but some time it count a wrong number.
Ok can you please answer me this question
How can i sum up all the amount in Pay column?
Thanx again.
Oct 1 '07 #8
jrtox
89
Hello,
Thanks a loooooooooooooooooooot.
Its working.
Thanks again.
I m also using another command for counting but some time it count a wrong number.
Ok can you please answer me this question
How can i sum up all the amount in Pay column?
Thanx again.

Just Used the Sum() Function

Take this example of SUM() Function

SELECT SUM(salary) as "Total Salary"
FROM employees

Regards
Ervin
Oct 2 '07 #9

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

Similar topics

1
by: Sourabh | last post by:
Hello, I am trying to write a VB.NET monitoring application for a MS SQL server. For that I need to know the following: 1. How do I count the number of read/write accesses per database on the...
1
by: Sourabh | last post by:
Hello, I am trying to write a VB.NET monitoring application for a MS SQL server. For that I need to know the following: 1. How do I count the number of read/write accesses per database on the...
7
by: C White | last post by:
A little while back I had a question about counting records and my example was something like this: in my database table i have the following records john ed john rick tom
3
by: Megan | last post by:
hi everybody- i'm having a counting problem i hope you guys and gals could give me some help with. i have a query that retrieves a bevy of information from several different tables. first let...
20
by: Protoman | last post by:
OK, this code compiles, links, and executes, but, how do I setup, like, a spinlock to query the DataBase object's status to let the SmrtPtr know that the object's been deleted?: #pragma once ...
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...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.