Solved

sql statement for count in mysql

Posted on 2008-06-14
3
188 Views
Last Modified: 2010-03-20
SELECT `Ssurname`
, SUM(CASE WHEN ((`status`= '11' ) or  (`status`= '12' ) ) THEN 1 ELSE 0 END) as Rows_Status_11
, SUM(CASE WHEN ((`status`!= '11' ) AND(`status`!= '12' ) ) THEN 1 ELSE 0 END) as Rows_Status_not_11,(select  count(*) as tol where ( (`status`= '11' ) or  (`status`= '12' )) form member_copy1 )
from member_copy1
GROUP BY `Ssurname`
Order by Rows_Status_11 Desc

sql above is not work please help to correct it

may be (select  count(*) as tol where ( (`status`= '11' ) or  (`status`= '12' )) form member_copy1 ) is not correct
0
Comment
Question by:teera
3 Comments
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 150 total points
ID: 21785014
Please print "mysql error" information.

The word, "form" might need to be "FROM" ??
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 300 total points
ID: 21785270
this should do it:
SELECT `Ssurname` 

, SUM(CASE WHEN ((`status`= '11' ) or  (`status`= '12' ) ) THEN 1 ELSE 0 END) as Rows_Status_11

, SUM(CASE WHEN ((`status`!= '11' ) AND(`status`!= '12' ) ) THEN 1 ELSE 0 END) as Rows_Status_not_11

, SUM(CASE WHEN (`status`= '11' ) or  (`status`= '12' ) THEN 1 ELSE 0 END) AS Rows_11_12

from member_copy1 

GROUP BY `Ssurname` 

Order by Rows_Status_11 Desc

Open in new window

0
 
LVL 32

Assisted Solution

by:awking00
awking00 earned 50 total points
ID: 21788964
You have your where clause before the from (form) clause.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

867 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now