Home Creating a pivot based on rules
Reply: 0

Creating a pivot based on rules

user837
1#
user837 Published in July 17, 2018, 7:56 am

I have a dataset like:

+---------------+----+
| Grade         | ID |
+---------------+----+
| Copper        | 1  |
+---------------+----+
| Copper        | 2  |
+---------------+----+
| Copper Bonded | 2  |
+---------------+----+
| Fiber         | 3  |
+---------------+----+
| Fiber         | 4  |
+---------------+----+

I would like a result like this:

+----+--------+
| ID | Copper |
+----+--------+
| 1  | A      |
+----+--------+
| 2  | B      |
+----+--------+
| 3  | C      |
+----+--------+
| 4  | C      |
+----+--------+

The ruleset is something like this:

A :  Copper only
B :  Copper and Copper Bonded
C :  Fiber only

Is this a candidate for a pivot, how do I express this as a sql query?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.495516 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO