Click here to Skip to main content
15,886,362 members

Can anyone help me to get this output in a required format please ?

Raj 0203 asked:

Open original thread
Here is my sql table data,
----------------------
HTML
ID	Team	Emp	Status
1	PP	H001	Active
2	AR	H002	In-Active
3	BL	H003	Active
4	EN	H004	Active
5	PP	H005	Active
6	AR	H006	Active
7	BL	H007	In-Active
8	EN	H008	In-Active
9	PP	H009	In-Active
10	AR	H010	In-Active
11	BL	H011	Active
12	EN	H012	In-Active
13	PP	H013	Active
14	AR	H014	Active
15	BL	H015	In-Active
16	EN	H016	In-Active

--------------------------

And now i need output is like,
---------------------------
HTML
Status	   PP	AR	BL	EN
Active	   3	2	2	1
In-Active	1	2	2	3

---------------------------


Please help me out of this.

Thanks in advance.

What I have tried:

Itried this,
---------------------
SQL
SELECT  Status, count(*) FROM [Tbl_Code] group by Status

---------
Tags: SQL Server, SQL Server 2008R2

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900