473,386 Members | 1,630 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,386 software developers and data experts.

Colum that has more than 1 comparison (in where clause) that must be counted

2
My problem is the following:

I need to count the number of diffrent letters that were printed for each account.
To do this for one value of a colum is easy in the where clause:
SELECT Count([TAKSIE].[AKDOK]) AS [1st Demand], [TAKSIE].[ACNO]
FROM TAKSIE
WHERE ([TAKSIE].[ADAT]<>" ") AND ([TAKSIE].[AKDOK] = "SABC.RTF")
GROUP BY [TAKSIE].[ACNO]

This query will tell me there is for acount number (ACNO) AA0000 10 SABC.RTF letters.

But now I want to know the where (ACNO) AA0000 has 10 SABC.RTF letters,
How many FPTP.RTF (failed ptp letters does he have, and PTC.RTF, and SREM.RTF ec.)

How do I write a query that will combine all this information in one query?
A UNION, only tells for each account individually how many letters he has.
I need in one row, the account, then the number of SABC.RTF (letters), FPTP.RTF (letters), PTC.RTF (Letters)


I have tried the following but it doesn't give me the correct totals:

SELECT Count([TAKSIE].[AKDOK]) AS [FailedPTP], Count([TAKSIE].[AKDOK]) AS [PTC], Count([TAKSIE].[AKDOK]) AS [1stDemand],
[TAKSIE].[ACNO]
FROM TAKSIE
WHERE [TAKSIE].[ADAT]<>" " AND ( [FailedPTP] = "FPTP.RTF") AND ( [PTC]= "PTC.RTF") AND ( [PTC]= "SABC.RTF")
GROUP BY [TAKSIE].[ACNO]

however it sees the values pf [failedPTP] as input that the user muss give..
Nov 23 '06 #1
3 1495
NeoPa
32,556 Expert Mod 16PB
Try this, but I suspect the WHERE clause will fail.
Let me know what type of field [ADAT] is and what you want done with it and I'll revise the SQL for you.
Expand|Select|Wrap|Line Numbers
  1. SELECT [ACNO], [AKDOK], Count([AKDOK]) AS [Failed]
  2. FROM TAKSIE
  3. WHERE [ADAT]<>" "
  4. GROUP BY [ACNO], [AKDOK]
Nov 23 '06 #2
MMcCarthy
14,534 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT [TAKSIE].[ACNO],
  3. DCount("[AKDOK]","[TAKSIE]","[ACNO]=" & [ACNO]) AS [1st Demand],
  4. Sum(IIf([AKDOK]='SABC.RTF', 1, 0) AS CountSABC,
  5. Sum(IIf([AKDOK]='FPTP.RTF', 1, 0) AS CountFPTP, 
  6. Sum(IIf([AKDOK]='PTC.RTF', 1, 0) AS CountPTC
  7. FROM TAKSIE
  8. WHERE [TAKSIE].[ADAT]<>" "
  9. GROUP BY [TAKSIE].[ACNO];
  10.  
Try this ...
Nov 23 '06 #3
Bennie
2
Thx alot, that really helped alot. I always wondered if you could use a If-statement with a query. That just solved alot of my problems!
Nov 28 '06 #4

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

Similar topics

125
by: Rhino | last post by:
One of my friends, Scott, is a consultant who doesn't currently have newsgroup access so I am asking these questions for him. I'll be telling him how to monitor the answers via Google Newsgroup...
2
by: Gregory | last post by:
Hi, One of the disadvantages of using error handling with error codes instead of exception handling is that error codes retuned from a function can be forgotten to check thus leading to...
5
by: Danilo Kempf | last post by:
Folks, maybe one of you could be of help with this question: I've got a relatively portable application which I'm extending with a plugin interface. While portability (from a C perspective) is...
3
by: Carlos Fandango | last post by:
I am converting a C# sample and have not use VB in years, I suspect this will not be my first post; I have a event declared as; Namespace Callisto.Utils.UI.Navigation ' <summary> ' A...
109
by: sonugeetha | last post by:
Hi, Please help me in this regard... All the kernel level programs are written in C... (i.e: Open Source LINUX)... Why are they not using C++... I personally feel that C++ is more easy to code...
14
by: Spoon | last post by:
Hello, I've come across the following comparison function used as the 4th parameter in qsort() int cmp(const void *px, const void *py) { const double *x = px, *y = py; return (*x > *y) -...
2
by: Stevie | last post by:
Hello I'm trying to work out the regular expression for carrying out a simple 'greater than' comparison. I have a directory with files such as asd345.log, asd346.log, asd347.log and so on.
5
by: mail | last post by:
Urgent help needed! I moved an application from ASP+ACCESS to ASP+MS SQLSERVER and I have the following problem: If the join on two tables results on duplicate colum names (which appear in...
5
by: fade | last post by:
Good afternoon, I need some advice on the following: I've got a class that has a member std::vector<CStringm_vFileName and a member CString m_path; The vector contains a bunch of filenames with...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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...

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.