473,396 Members | 2,070 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 the Repetition of a Text Field in the Same Table

3
I have a table which can have records almost repeated set of records except the difference of the a filed which is a flag.
this flag can have either a value CSI or CCN . I want to count the no CCN records of respective CSI records and show with this

Eg: Records come like

Charge1 200.00 34344 CSI
Charge2 150.25 34345 CSI
Charge1 75.00 562 CCN
Charge1 25.00 563 CCN
Charge2 65.00 564 CCN

I want to fetch a records should like
Charge1 200.00 CSI 2 (CCN Count of the Charge1)
Jan 23 '07 #1
4 2447
nico5038
3,080 Expert 2GB
When you just want CSI and CSS, use:

Expand|Select|Wrap|Line Numbers
  1. select CSI-CCN_field, count( CSI-CCN_field) as CountOfCSI-CCN_field 
  2. from tblYours
  3. Group By CSI-CCN_field;
This will give:
CSI 2
CCN 3

Nic;o)
Jan 23 '07 #2
NeoPa
32,556 Expert Mod 16PB
I've assumed (as you didn't say) a table layout as below and that there is always one CSI record to a group of CCN records.
Expand|Select|Wrap|Line Numbers
  1. Table Name = [MyTable]
  2. Code; Text
  3. Charge; Currency
  4. Flag; Numeric
  5. Type; Text (CSI or CCN)
[code]SELECT CSI.Code,
CSI.Charge,
CSI.Type,
Count(CCN.Code) AS CCNCount
FROM MyTable AS CSI LEFT JOIN
MyTable AS CCN
ON CSI.Code=CCN.Code
WHERE ((CSI.Type='CSI') AND (CCN.Type='CCN'))
GROUP BY
Jan 23 '07 #3
BinuKJ
3
CSI is the definite record and happened only once against each Unique JOB. CCN can occur any no of times with each JOB so when i want to see each job that with CSI values want to see how many CCN also generated against that JOB

I've assumed (as you didn't say) a table layout as below and that there is always one CSI record to a group of CCN records.
Expand|Select|Wrap|Line Numbers
  1. Table Name = [MyTable]
  2. Code; Text
  3. Charge; Currency
  4. Flag; Numeric
  5. Type; Text (CSI or CCN)
[code]SELECT CSI.Code,
CSI.Charge,
CSI.Type,
Count(CCN.Code) AS CCNCount
FROM MyTable AS CSI LEFT JOIN
MyTable AS CCN
ON CSI.Code=CCN.Code
WHERE ((CSI.Type='CSI') AND (CCN.Type='CCN'))
GROUP BY
Mar 14 '07 #4
NeoPa
32,556 Expert Mod 16PB
Have you tried the SQL code I posted?
If so, what results did you get?
Mar 14 '07 #5

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

Similar topics

14
by: Mike N. | last post by:
Hello: I have a form that contains a multiple-select field that has 12 options in it. I would like the user to be able to select UP TO FOUR of those options. If they select more than four, I...
2
by: Glenn Cornish | last post by:
I have 5 fields in a table into which numbers between 1 and 45 can be entered. What I am having trouble with is being able to find out is how many times a particular number appears, regardless of...
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...
5
by: chrisc | last post by:
Hello, Hope this is the right place for this... I am creating a testing database for components as they come off a production line. My reports need to select faults that are found, as well...
5
by: ChadDiesel | last post by:
Hello Again, I want to assign a number to each record that will be part of a shipping number. I want the number value to count up until the contract number changes. Then, I want the number to...
18
by: ChadDiesel | last post by:
I appreciate the help on this group. I know I've posted a lot here the last couple of weeks, but I was thrown into a database project at my work with very little Access experience. No other...
7
by: sathyashrayan | last post by:
Group, Following function will check weather a bit is set in the given variouble x. int bit_count(long x) { int n = 0; /* ** The loop will execute once for each bit of x set,
4
by: Dado | last post by:
I have a next situation with the textbox field: A - B = C 1. How to fill the A fill with the data from my previous recordset ? Can I do it with the expression builder ? 2. I want that every...
3
by: martin DH | last post by:
Access 2003 I have a table (TASKS) filled with data from an external source. The table lists several tasks for employees to complete and has a text field (STATUS) that identifies where in the...
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
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?
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
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
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,...
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
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.