Riddhi Valecha

Riddhi Valecha

  • 445
  • 3.3k
  • 413.7k

SQL Query - CASE Statement - URGENT

Nov 28 2016 5:10 AM
Hello all,
 
My Requirement is-
I have a table with details of - Devices, Subdevices and hostnames (all computer systems details).
Now, I want to display the result as -
1. When host name contains "scrap" or "temp" values, then Hostname must be blank.
2. When device type is ThinClient , then Hostname must be "N/A"
 
Please help me to make the query ..
 
Eg -

Original Table -

ID

Device

SubDevice

HostName

1

Desktop

Desktop

H1

2

Laptop

Laptop

H2

3

ThinClient

ThinClient

 

4

Desktop

Desktop

Scrap

5

Laptop

Laptop

Scrap

6

ThinClient

ThinClient

 

7

Desktop

Desktop

Temp

8

Laptop

Laptop

H3

9

ThinClient

ThinClient

 

10

Laptop

Laptop

H4

Output as

ID

Device

SubDevice

HostName

1

Desktop

Desktop

H1

2

Laptop

Laptop

H2

3

ThinClient

ThinClient

N/A

4

Desktop

Desktop

 

5

Laptop

Laptop

 

6

ThinClient

ThinClient

N/A

7

Desktop

Desktop

 

8

Laptop

Laptop

H3

9

ThinClient

ThinClient

N/A

10

Laptop

Laptop

H4


Answers (7)