i hav a table with a column named result where values are either of the three
pass ,fail,absent
can i get multiple count in same row
like - select count(result=pass) as cp,count(result=fail) as cf,count(result=absent) as ca;
i know about three select count statements with three where clause
What about something like - SELECT SUM(IF(result=pass,1,0)) AS cp,
-
SUM(IF(result=fail,1,0)) as cf,
-
SUM(IF(result=absent,1,0)) as ca
Not sure if this will work
9 2916
What about something like - SELECT SUM(IF(result=pass,1,0)) AS cp,
-
SUM(IF(result=fail,1,0)) as cf,
-
SUM(IF(result=absent,1,0)) as ca
Not sure if this will work
Atli 5,058
Expert 4TB @code green
It does. I just tried it. (Had to know if it worked xD)
You forgot to quote the strings tho.
Nice thinking, btw. My mind was already going for multiple self joins or sub-queries :P
Nice thinking, btw. My mind was already going for multiple self joins or sub-queries :P
Thanks! Multiple self-join was also in my thoughts. Probably got solution because I am always confusing COUNT and SUM
@Atli - SELECT COUNT( IF(PASS_FAIL='P',1,0)) AS cp,COUNT ( IF(PASS_FAIL='F',1,0)) as cf,COUNT( IF(PASS_FAIL='A',1,0)) as ca
-
FROM cm0909
-
WHERE (((cm0909.YEAR)=2008) AND ((cm0909.STU_TYPE)=1) AND ((cm0909.SEX_CODE)="M"));
THIS GIVES ERROR
ERROR UNDEFINED FUNCTION IF IN EXPRESSION
Atli 5,058
Expert 4TB
Which database system are you using?
Only hits I can get on that error are related to Access, not MySQL.
In which case you could try IIF instead of IF. (I think.) @Atli
ya m using access temperorily bcoz i cant import data in mysql
as my sql limit is (Max: 2,048KB)
and my file size is 11.1 mb
kindly also suggest how to import this file
@kkshansid
thanx a lot for ur valuable guidance bt kindly solve my import problem
Atli 5,058
Expert 4TB
Well, MySQL queries and Access queries aren't exactly the same.
You shouldn't expect MySQL queries to work flawlessly under Access, nor the other way around.
Also, these sort of details are handy for us to have before hand, so we don't waste time debugging Access errors for perfectly fine MySQL queries.
Atli 5,058
Expert 4TB @kkshansid
Discussing two separate topics in the same thread is generally not a good idea, and we avoid that whenever possible.
So if you want to start a discussion on your import problems, please post your question in a new thread.
Make sure to post all relevant information, such as the details on your MySQL server, your previous attempts to import your data and why/how you were unsuccessful.
Thanks.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ben Hallert |
last post by:
Hi guys,
I'm trying to figure out what bone headed mistake I made on something I
put together. I've got a form (named 'context') that has a variable
number of select-multiple inputs on it. ...
|
by: Christopher Harrison |
last post by:
Is there a way to store an indefinite number of keys in one field and
self join them? Imagine, for example, you have a table of users with a
"friends" column. Say user 1 is friends with users 9, 7,...
|
by: Dolorous Edd |
last post by:
Hi,
for a program I'm working on I need to be able to drag multiple files
between Windows Explorer and a ListBox, in both directions.
Implementing the "drag in" was pretty easy, but I can't find...
|
by: Dave Edwards |
last post by:
I understand that I can fill a datagrid with multiple queries, but I cannot
figure out how to fill a dataset with the same query but run against
multiple SQL servers, the query , table structure...
|
by: Bill |
last post by:
Hi
I am trying to get my listbox items to print if they stream past the one
page mark. my code is working for one page of information (if the
e.hasmorepages) is not there.
But I am having...
|
by: Phoenix_ver10 |
last post by:
I have a mailing list with multiple names going to the same addresses.
I need one address with all the names for that address on it. I checked
out the example on microsoft's site, but A: It doesn't...
|
by: bonneylake |
last post by:
Hey Everyone,
Well i was hoping someone could explain the best way i could go about this.
i have a few ideas on how i could go about this but i am just not sure if it would work.
Right now i...
|
by: bonneylake |
last post by:
Hey Everyone,
Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also...
|
by: bonneylake |
last post by:
Hey Everyone,
Well i am not sure if this is more of a coldfusion problem or a javscript problem. So if i asked my question in the wrong section let me know an all move it to the correct place.
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
|
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: 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...
|
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,...
| |