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

i get multiple count in same row

232 100+
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
Expand|Select|Wrap|Line Numbers
  1. 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
Sep 22 '09 #1

✓ answered by code green

What about something like
Expand|Select|Wrap|Line Numbers
  1. SELECT SUM(IF(result=pass,1,0)) AS cp,
  2. SUM(IF(result=fail,1,0)) as cf,
  3. SUM(IF(result=absent,1,0)) as ca
Not sure if this will work

9 2916
code green
1,726 Expert 1GB
What about something like
Expand|Select|Wrap|Line Numbers
  1. SELECT SUM(IF(result=pass,1,0)) AS cp,
  2. SUM(IF(result=fail,1,0)) as cf,
  3. SUM(IF(result=absent,1,0)) as ca
Not sure if this will work
Sep 22 '09 #2
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
Sep 22 '09 #3
code green
1,726 Expert 1GB
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
Sep 23 '09 #4
kkshansid
232 100+
@Atli
Expand|Select|Wrap|Line Numbers
  1. 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
  2. FROM cm0909
  3. WHERE (((cm0909.YEAR)=2008) AND ((cm0909.STU_TYPE)=1) AND ((cm0909.SEX_CODE)="M"));
THIS GIVES ERROR
ERROR UNDEFINED FUNCTION IF IN EXPRESSION
Sep 30 '09 #5
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.)
Oct 1 '09 #6
kkshansid
232 100+
@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
Oct 1 '09 #7
kkshansid
232 100+
@kkshansid
thanx a lot for ur valuable guidance bt kindly solve my import problem
Oct 1 '09 #8
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.
Oct 1 '09 #9
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.
Oct 1 '09 #10

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

Similar topics

6
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. ...
6
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,...
2
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...
4
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...
6
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...
1
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...
92
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...
58
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...
482
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. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
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.