Ask Your Question
0

How can you establish predetermined values for a column when using the select statement?

asked 2023-06-19 07:13:58 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-06-19 07:37:01 +0000

lakamha gravatar image

You can establish predetermined values for a column when using the select statement by using the "CASE" statement:

SELECT column1, column2, CASE WHEN column3 >= 10 THEN 'High' WHEN column3 >= 5 THEN 'Medium' ELSE 'Low' END AS 'Priority' FROM table_name;

In this example, the values in column3 are evaluated and a new column (Priority) is created with predetermined values based on the criteria in the CASE statement.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-19 07:13:58 +0000

Seen: 11 times

Last updated: Jun 19 '23