Solved

sql staement for my ql to count

Posted on 2008-06-14
1
163 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
ID: 21784814
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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

22 Experts available now in Live!

Get 1:1 Help Now