0

the sql:

SELECT 
id, COUNT(id) AS Counter
FROM tableA  
GROUP BY id

the result:

enter image description here

the goal is to do like below:

enter image description here

to combine the (NULL ID) with ID=09 so that it will 0+1=1, give proper naming to the id will be great too, like

ID             Counter
NULLWITH09        1
THE 01           467
THE 02            8

any help would be great.. thanks

1 Answer 1

1

untested, but something like this:

SELECT 
'THE ' +id, COUNT(id) AS Counter
FROM tableA
where id is not null and id<>9  
GROUP BY id
UNION ALL
SELECT 
'null and 9', COUNT(*) AS Counter
FROM tableA
where id is null or id=9  
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.