Solved

continue - Subtypes count

Posted on 2009-07-08
2
167 Views
Last Modified: 2012-05-07
See related question.

How would I return 1 row with all the subtypes.  
The return row should be:
Id, T1S1, T1S2, T1S3, T2S1,T2S2,T2S3
T1S1 means Type=1 SubType=1, T2S1 means Type=2 and SubType=1 etc.
T1S1,T1S2... should show how many subtypes exist.
0
Comment
Question by:johnkainn
2 Comments
 
LVL 57

Accepted Solution

by:
Raja Jegan R earned 500 total points
ID: 24802355
Hope this helps
SELECT ID, sum( CASE WHEN Type=1 AND SubType=1 THEN 1 ELSE 0 END) T1S1,
sum( CASE WHEN Type=1 AND SubType=2 THEN 1 ELSE 0 END) T1S2,
sum( CASE WHEN Type=1 AND SubType=3 THEN 1 ELSE 0 END) T1S3,
sum( CASE WHEN Type=2 AND SubType=1 THEN 1 ELSE 0 END) T2S1,
sum( CASE WHEN Type=2 AND SubType=2 THEN 1 ELSE 0 END) T2S2,
sum( CASE WHEN Type=2 AND SubType=3 THEN 1 ELSE 0 END) T2S3
FROM ur_table
GROUP BY ID

Open in new window

0
 
LVL 2

Expert Comment

by:sunil_mails
ID: 24803600
put ur table structure to help experts gv u perfect solution.. if possible put 4-5 sample rows
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 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

10 Experts available now in Live!

Get 1:1 Help Now