[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Sub Query count with distcint

Posted on 2006-05-03
11
Medium Priority
?
387 Views
Last Modified: 2008-01-09
how would I write a sub query with distinct and count
0
Comment
Question by:thenone
  • 4
  • 4
  • 2
  • +1
11 Comments
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 1000 total points
ID: 16602716
Perhaps you can elaborate so that we do not have to speculate.
0
 
LVL 8

Author Comment

by:thenone
ID: 16602726
sure I do not want the count of the unique records returned because if I do a select distinct count(8) as counting,column1 from table

I recieve just a count of the unique records returned.I need a true count.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16602783
**Confused** Is this what you are looking for:
Select COUNT(*) As MyCount From YourTable

Also, you should mention your database so that we can post the correct SQL syntax.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16602792
Never mind, I see that:
A.  That is the same response you got in another thread and
B.  You are using a database that I know next to nothing about.  Namely MySQL
0
 
LVL 8

Author Comment

by:thenone
ID: 16602805
mysql
0
 
LVL 4

Expert Comment

by:senthil_msv
ID: 16604089
i cann't understand your question.. Can you explain your problem with some more details..

And also pls mention the mysql version...

0
 
LVL 4

Expert Comment

by:senthil_msv
ID: 16604106
Select count(Distinct FieldName) as cntRecords From TableName
0
 
LVL 8

Author Comment

by:thenone
ID: 16605066
Mysql 5.0. I have a two part select statement from the same table.First I need to count the records and second I need to select the distinct records.How would this query work?

Select count(Distinct FieldName) as cntRecords From TableName <<<I have tried this and I recieve an error.

0
 
LVL 22

Accepted Solution

by:
WMIF earned 1000 total points
ID: 16607800
is something like this what you are looking for?

select distinct col1,
(select count(col1) from table) as col1count
from table
0
 
LVL 8

Author Comment

by:thenone
ID: 16611204
ok but when i do that, it doesn't return the amount of records that will displayed I mean the count.

I have a distinct select with a count and a limit.What I need to do is even though the limit is 30 records I still want to display the total records found.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16611835
>>What I need to do is even though the limit is 30 records I still want to display the total records found.<<
Than you have no choice:  You have to remove the LIMIT
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question