alexa

how to update a tag column based on multiple values against an ID column in SQL ?

how to update a tag column based on multiple values against an ID column in SQL ?

If this is just something you want to view, adhoc, then the below will work, as it does not set anything in the tables:

This code will add a column with the status for every line:

 SELECT 
    [Customer ID],
    Product,
    Status,
    CASE
        WHEN
            Status = 'Paying'
                THEN
                    'Active'
        WHEN
            Status = 'Paying-Installment'
                THEN
                    'Active'
        ELSE
            'Inactive'
        END AS Active
FROM customerTable 

This code will add a column with the status but only show the customer and the status:

 SELECT DISTINCT
    [Customer ID],
    CASE
        WHEN
            Status = 'Paying'
                THEN
                    'Active'
        WHEN
            Status = 'Paying-Installment'
                THEN
                    'Active'
        ELSE
            'Inactive'
        END AS Active
FROM customerTable 

The difference between the two is what columns are shown, and the DISTINCT command.


292 0
7

Write a Comments


* Be the first to Make Comment

GoodFirms Badge
GoodFirms Badge

Fix Your Meeting With Our SEO Consultants in India To Grow Your Business Online

Facebook
Twitter
LinkedIn
Instagram
Whatsapp
Call Now
Quick Inquiry