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

How to use two count() in a single query???

43
is it possible to use two count(*) in a query
over same table.
i have a table with 2 columns

Name Status
a true
b false
c false
d true

i need to run a query which will give me
Total=4
True=2
false=2
Thanks in advance
Dec 19 '07 #1
5 5513
amitpatel66
2,367 Expert 2GB
is it possible to use two count(*) in a query
over same table.
i have a table with 2 columns

Name Status
a true
b false
c false
d true

i need to run a query which will give me
Total=4
True=2
false=2
Thanks in advance
Try this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT COUNT(*),SUM(COUNT(*)) FROM table GROUP BY status;
  3.  
  4.  
Dec 19 '07 #2
bravo
43
Try this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT COUNT(*),SUM(COUNT(*)) FROM table GROUP BY status;
  3.  
  4.  
SUM(COUNT(*)) it is not acceptable i have tried it already before this post
got
Invalid use of group function
error
Dec 19 '07 #3
amitpatel66
2,367 Expert 2GB
SUM(COUNT(*)) it is not acceptable i have tried it already before this post
got
Invalid use of group function
error
Try this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT COUNT(*),(SELECT COUNT(*) FROM table) FROM TABLE GROUP BY STATUS;
  3.  
  4.  
Dec 19 '07 #4
bravo
43
Try this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT COUNT(*)as Total,(SELECT COUNT(*) FROM TABLE1 where status='True'),(SELECT COUNT(*) FROM TABLE1 where status='false') FROM TABLE1 ;
  3.  
  4.  
  5.  
Thanks for ur reply ...
above is what exactly i required and it worked....
thanks again...
Dec 19 '07 #5
amitpatel66
2,367 Expert 2GB
Thanks for ur reply ...
above is what exactly i required and it worked....
thanks again...
You ar welcome :)

MODERATOR
Dec 19 '07 #6

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

Similar topics

1
by: FatBoyThin | last post by:
I love it when I back myself into a corner. Seems to be the fastest way to learn. I have 3 tables; tblINBOX, tblOUTBOX and tblPENDING The relevant rows are as following; Date, userID userID is...
5
by: Cro | last post by:
Hello Access Developers, I'd like to know if it is possible to perform a count in an expression that defines a control source. My report is based on a query. In my report, I want a text box to...
3
by: Abhi | last post by:
Hi! I am wondering if this query is possible somehow: I have a table with many fields that all can have a value from 1 to 5. if I wanna see the count of each value from one field, then this...
4
by: Anuradha | last post by:
Dear Experts How can I count records in a data reader? Thx Anuradha
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
3
by: Auddog | last post by:
I have the following query that works in mysql: select id, order_no, price, count(item_no), sum(price) from production WHERE item_no = '27714' group by item_no; When I setup my query in php,...
9
by: Akhenaten | last post by:
The following snippet (for whatever reason) returns no value for the count. Suggestions? $arr = array ("A", "B", "C", "D", "E"); foreach ($arr as $client) { $count = mysql_query('SELECT...
2
by: Pete | last post by:
I need to create a single query (Not a SQL query) against a single table that counts the number of records in the table, where the single field "tmp" contains specific string values If the field...
3
by: epiphyte | last post by:
Let's say I have a table with a list of young folk (table1). This table is related to a table that lists all their booty calls (table2). A third table lists their booty calls' booty calls (table3)....
1
by: dez5000 | last post by:
I'm trying to get a report by location that would list the number of visits to the location for the month but also count the number of unique visitors to that location. I have a table of data with...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.