October 23, 2024
Chicago 12, Melborne City, USA
SQL

How to separate category based on invoice Date, invoice number and category


I have a table like below

Date Bill No Category
30-09-2024 1 VSS
1-10-2024 2 RSS
1-10-2024 3 VSS
1-10-2024 3 RSS
1-10-2024 4 RSS
1-10-2024 4 RSS

I need new category like below

Date Bill No Category New Category
30-09-2024 1 VSS VSS
1-10-2024 2 RSS RSS
1-10-2024 3 VSS VSS
1-10-2024 3 RSS VSS
1-10-2024 4 RSS RSS
1-10-2024 4 RSS RSS

Note: If bill Date is same and Bill No is duplicate and category is different then consider VSS.

I tried

SELECT Date, BillNo, Category 
    , case when [Category]='VSS' then 'VSS' else 'RSS' end [New CATEGORY] 
FROM TBL



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video