Solved

sql staement for my ql to count

Posted on 2008-06-14
1
162 Views
Last Modified: 2010-05-18
SELECT COUNT( * ) as Rows , `Ssurname` from member_copy1 where `status`= '11' GROUP BY `Ssurname` Order by Rows Desc


sql above is work but i want the result that  `status`!= '11' to show to compare too what can I do
0
Comment
Question by:teera
1 Comment
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
here we go:
SELECT `Ssurname` 
, SUM(CASE WHEN `status`= '11' THEN 1 ELSE 0 END) as Rows_Status_11
, SUM(CASE WHEN `status`= '11' THEN 0 ELSE 1 END) as Rows_Status_not_11
from member_copy1 
GROUP BY `Ssurname` 
Order by Rows_Status_11 Desc

Open in new window

0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 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

11 Experts available now in Live!

Get 1:1 Help Now