How to count more than one time with different conditions?Select when group by contains more than one row...
Does Windows 10's telemetry include sending *.doc files if Word crashed?
Strange Sign on Lab Door
Jumping Numbers
What does Cypher mean when he says Neo is "gonna pop"?
Why doesn't "auto ch = unsigned char{'p'}" compile under C++ 17?
Can you combine War Caster, whip, and Warlock Features to Eldritch Blast enemies with reach?
If I delete my router's history can my ISP still provide it to my parents?
Avoiding morning and evening handshakes
What is the purpose of easy combat scenarios that don't need resource expenditure?
Can a dragon be stuck looking like a human?
It took me a lot of time to make this, pls like. (YouTube Comments #1)
Is a debit card dangerous for an account with low balance and no overdraft protection?
How to deal with an incendiary email that was recalled
We are very unlucky in my court
Compress command output by piping to bzip2
How do I say "Brexit" in Latin?
What is this metal M-shaped device for?
Difference between two quite-similar Terminal commands
How can animals be objects of ethics without being subjects as well?
How do you funnel food off a cutting board?
Every character has a name - does this lead to too many named characters?
Why do members of Congress in committee hearings ask witnesses the same question multiple times?
Would these multi-classing house rules cause unintended problems?
What makes the Forgotten Realms "forgotten"?
How to count more than one time with different conditions?
Select when group by contains more than one row with the same value?how can we merge sum and count?MySQL: Delete all rows older than 30 days, but only if count more than oneGroup COUNT by month less than variableSelect only one duplicate with different time columnHow to select random row with count()MySQL group by multiple columns on multiple tables only one result per groupHow to group a few row values together to put into a new table?How to write group by and having in a relational algebra interpreter?how to count distinct value per day with start time and end time
Having a table like this:

I want to get a result like this:

Something like:
SELECT ParentId, COUNT(SomeValue = 1) [CountMin], COUNT(SomeValue > 1) [CountRest]
FROM MyTable
GROUP BY ParentId
sql-server sql-server-2016 query group-by
add a comment |
Having a table like this:

I want to get a result like this:

Something like:
SELECT ParentId, COUNT(SomeValue = 1) [CountMin], COUNT(SomeValue > 1) [CountRest]
FROM MyTable
GROUP BY ParentId
sql-server sql-server-2016 query group-by
add a comment |
Having a table like this:

I want to get a result like this:

Something like:
SELECT ParentId, COUNT(SomeValue = 1) [CountMin], COUNT(SomeValue > 1) [CountRest]
FROM MyTable
GROUP BY ParentId
sql-server sql-server-2016 query group-by
Having a table like this:

I want to get a result like this:

Something like:
SELECT ParentId, COUNT(SomeValue = 1) [CountMin], COUNT(SomeValue > 1) [CountRest]
FROM MyTable
GROUP BY ParentId
sql-server sql-server-2016 query group-by
sql-server sql-server-2016 query group-by
asked 4 mins ago
Erick Asto OblitasErick Asto Oblitas
11614
11614
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "182"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f231106%2fhow-to-count-more-than-one-time-with-different-conditions%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Database Administrators Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f231106%2fhow-to-count-more-than-one-time-with-different-conditions%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown