Luciano Nascimento
Luciano Nascimento

Reputation: 2600

Multiple Value for Custom Column

I would like to each ID have 2 Custom_Column values. How can I do that?

Example Table:

ID
1
2
3

Example Query:

SELECT id, (id*2) as Custom_Value, (id*4) as Custom_Value FROM numbers

Response:

ID    Custom_Value
1     2
1     4
2     4
2     8
3     6
3     12

Upvotes: 2

Views: 63

Answers (1)

John Woo
John Woo

Reputation: 263693

use UNION

SELECT ID, (ID*2) as CustomVal FROM tableNAme
UNION ALL
SELECT ID, (ID*4) as CustomVal FROM tableNAme
ORDER BY ID

Upvotes: 2

Related Questions