idk_meu
idk_meu

Reputation: 39

How to uppercase one thing but leave the other one none case sensitive?

Here's my query:

select invoice_number, invoice_date, invoice_total, invoice_due_date, date_format(invoice_due_date, 'Due in %M %Y') as month_due
from active_invoices

order by invoice_total desc

Here's my output

How can I make it to look like this?

Wanted output

Upvotes: 0

Views: 29

Answers (1)

Jon Ekiz
Jon Ekiz

Reputation: 1022

Use case statement to filter on June on July and apply different upper case conditions.

SELECT invoice_number
    , invoice_date
    , invoice_total
    , invoice_due_date
    , CASE 
        WHEN month(invoice_due_date) = 7
            THEN date_format(invoice_due_date, 'Due in %M %Y')
        WHEN month(invoice_due_date) = 6
            THEN date_format(invoice_due_date, 'DUE IN %M %Y')
        END AS month_due
FROM active_invoices
ORDER BY invoice_total DESC

Upvotes: 1

Related Questions