I have a table that looks like this:
CREATE TABLE [dbo].[Phrase]
(
[PhraseId] UNIQUEIDENTIFIER DEFAULT (newid()) NOT NULL,
[English] NVARCHAR (250) NOT NULL,
[p1] BIT DEFAULT ((0)) NOT NULL,
[p2] BIT DEFAULT ((0)) NOT NULL,
[p3] BIT DEFAULT ((0)) NOT NULL,
PRIMARY KEY CLUSTERED ([PhraseId] ASC),
CONSTRAINT [FK_PhrasePhraseChapter]
FOREIGN KEY ([ChapterId])
REFERENCES [dbo].[PhraseChapter] ([PhraseChapterShortId])
);
What I would like to do is to get a count of p1, p2 and p3 so the output looks something like:
p1 100
p2 200
p3 23
Note that in this case the first row would mean that there were 100 rows in the Phrase table that had p1 set to a value of 1. Hope this makes sense.
I know I could do this simply with three columns but I need a row output of just two string columns like above. Can anyone give me a suggestion as to how I could achieve this?