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

Count of table column

8
Hi,
i have a table xx with column flg.

it has values like

flg
----
T
G
T
T
G
G
G
G

I want to write a query that would retrieve
count(flg) where flg='G'
and count(flg) where flg='T'
in a single line query.
Jan 11 '08 #1
6 1936
amitpatel66
2,367 Expert 2GB
Hi,
i have a table xx with column flg.

it has values like

flg
----
T
G
T
T
G
G
G
G

I want to write a query that would retrieve
count(flg) where flg='G'
and count(flg) where flg='T'
in a single line query.
Expand|Select|Wrap|Line Numbers
  1. SELECT flg,COUNT(flg) from xx GROUP BY flg;
  2.  
  3. SELECT (SELECT COUNT(flg) from xx WHERE flg = 'G') G, (SELECT COUNT(flg) from xx WHERE flg = 'T') T FROM DUAL;
  4.  
  5.  
Jan 11 '08 #2
hgriva
8
Expand|Select|Wrap|Line Numbers
  1. SELECT flg,COUNT(flg) from xx GROUP BY flg;
  2.  
  3. SELECT (SELECT COUNT(flg) from xx WHERE flg = 'G') G, (SELECT COUNT(flg) from xx WHERE flg = 'T') T FROM DUAL;
  4.  
  5.  
Hi,
Thanks for your reply.
I need one more clarification.

if want count of flg where flg='G' and count of flg <>'G'
how would i get it
Jan 11 '08 #3
debasisdas
8,127 Expert 4TB
Hi,
Thanks for your reply.
I need one more clarification.

if want count of flg where flg='G' and count of flg <>'G'
how would i get it
Also try to use DECODE for the purpose.
Jan 11 '08 #4
amitpatel66
2,367 Expert 2GB
Hi,
Thanks for your reply.
I need one more clarification.

if want count of flg where flg='G' and count of flg <>'G'
how would i get it
Give a try to find a count for flg <> G using the ideas from the above post. Post back in case of any issues you face!!
Jan 11 '08 #5
hgriva
8
Thanks.I got the answer
Jan 11 '08 #6
amitpatel66
2,367 Expert 2GB
Thanks.I got the answer
We appreciate that!!...
Jan 11 '08 #7

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

Similar topics

6
by: Hari Om | last post by:
Here are the details of my error log files: I execute the command and get following message at console: ---------------------------------------------------------------------- ../sqlldr...
17
by: keith | last post by:
I am trying to get a exact count of different distinct entries in an Access column. At first, I was trying to work with three columns, but I've narrowed it down to one to simplify it. I've searched...
1
by: James | last post by:
Access 2003, trying to count the number of records that meet a criteria. According to Help: "In the Database window, click Queries under Objects, and then click New on the database window...
0
by: Tim Cowan | last post by:
Hi How do I get the column count for an HTML table?(System.Web.UI.HtmlControls.HtmlTable) I want to add rows at the beginning of the table for standard header and info text, but the tables...
8
by: Doug Bell | last post by:
Hi, I need to create a function that will return the number of columns in a passed reference to a DataView. I can find the number of columns in its underlying Data table but have not been...
2
by: DrewKull | last post by:
Ok ... so I'm looking at a query where im trying to show a bunch of columns counted up based on criteria ... So far i've been able to count all the rows up and show them ... and also count up...
7
by: hjohnson | last post by:
Within the access environment, I have a table that I'd like to -add a column -place the record number of each record into that column The autonumber is not working for me because I am...
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...
1
newnewbie
by: newnewbie | last post by:
Desperately need help in creating a query to count unique values in a table. I am a Business analyst with limited knowledge of Access….My boss got me ODBC connection to the underlying tables for our...
0
by: imran haq | last post by:
Hi All, I have 3 rather Long Questions that are causing alot of trouble: I would appreciate all the help i can get and tried to use A post sent to atli in the past but it did not help... !) I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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...
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...

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.