How to use count using case statements

How to use count using case statements

I am trying to get the total number of items and categorize them using case statements. However, I keep getting the items (which are now categorized as "inv") repeated (e.g. "clothes" is repeated 4 times, each with a count of 1 instead of just once with the total count of 4) - how do I get rid of that? I included the desired outcome below.

I am trying to get the total number of items and categorize them using case statements. However, I keep getting the items (which are now categorized as "inv") repeated (e.g. "clothes" is repeated 4 times, each with a count of 1 instead of just once with the total count of 4) - how do I get rid of that? I included the desired outcome below.

Here's my table:

TABLE BOX1

ITEM_NO ITEM             DATE
===================================
3130C   MARVEL_SHIRT     01-JAN-17
1845C   SPONGEBOB_BOXERS 03-DEC-18
A900C   CK_COAT          04-DEC-18
A988C   RIDER_JEANS      11-JAN-19
L350T   BARBIE           23-NOV-18
L129T   LEGO             09-OCT-18
LXZYT   BATMAN_FIG1      12-JAN-19

My code:

select (case substr (item_no,5,1)
    when 'C' then 'clothes'
    when 'T' then 'toys' else 'misc' end) inv, 
    count(item_no) total 
from box1 where date <= sysdate
    group by item

Desired Outcome:

INV     TOTAL
===============
CLOTHES 4
TOYS    3


sql oracle database

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Introduction to Structured Query Language SQL pdf

SQL stands for Structured Query Language. SQL is a scripting language expected to store, control, and inquiry information put away in social databases. The main manifestation of SQL showed up in 1974, when a gathering in IBM built up the principal model of a social database. The primary business social database was discharged by Relational Software later turning out to be Oracle.

Introduction to Structured Query Language SQL pdf

SQL stands for Structured Query Language. SQL is a scripting language expected to store, control, and inquiry information put away in social databases. The main manifestation of SQL showed up in 1974, when a gathering in IBM built up the principal model of a social database. The primary business social database was discharged by Relational Software later turning out to be Oracle.

Exploring PL/SQL Nested Tables in Oracle

In this tutorial, you will learn how to declare and initialize Oracle PL/SQL collections (Nested Tables). Nested tables are very similar to the PL/SQL tables, which are known in Oracle as index-by tables.

AlaSQL in Action: The JavaScript SQL Database

Overview on AlaSQL, the popular lightweight client-side in memory SQL database, including a real life example of AlaSQL in action. I was surprised to see that there aren’t more posts about this popular lightweight client-side in-memory SQL database online apart from this awesome article I found.

Backup Database using T-SQL Statements

Introduction In this article, We will discuss how to backup our database in MS-SQL Server using T-SQL Statements. We need to use BACKUP DATABASE statement to create full database backup, along with…