SQL SELECT Clause | Querying Data from Single Table

SQL SELECT Clause: The SQL SELECT clause have multiple parameters and clause to deal with, we will check multiple clauses and also, we can use multiple athematic operation (addition, subtraction, multiplication, division & Remainder)

SQL SELECT Clause

In previous message I have seen on simple select statement and later we have discussed about different where clause in the select statement.

We can use multiple SQL SELECT Clause to get the details of with arithmetic operation like addition, subtraction, multiplication, division and remainder as well.

SELECT first_name, last_name, points,
      points+50,
      points-2,
      points*2,
      points/2,
      (points + 10) * 100 AS 'updated_points'
FROM customers;

As you can see in the above image, we can see the 2nd, 3rd, 4th and 5th line is operations such as addition, subtraction, multiplication and many more operations.

SQL SELECT Clause

— 1. We can use ‘*’ to return all the column or specify the column you want to return (first_name, last_name, points).

— 2. We can use arithmetic operation in select commands like (+ ” – ” * ” / ” %) to perform operations and give new value [(points + 10) * 100].

— 3. “AS” is used as Alais Name for the update’s column.

— 4. Always use AS name within double quote and single quote (“” or ”). If you don’t specify then you can’t specify name’s having space in b/w them.

— 5. We can also use DINSTINCT keyword to get unique list of data. Specify the DINSTINCT at the beginning of the select statement.

SQL Select clause main operation is to get data from single table and also multiple tables with sub-queries and joins. Click here! to get more info:

Note:

  1. when you use addition with multiplication, then the multiplication will be executed first as SQL will consider this as high priority.
  2. If you want to that addition must be executed first, then you have to specify that in braces.
  3. In the above example you can see that first I have added the points with 10 and then multiply by 100 to say SQL that first execute the “()” terms and then multiply it.

Watch Video!

Next Post>> #2.3) Where Clause (Single Table)

<< Previous Post #2.1) The Select Statement (Single Table)

Vickey Rajpoot
Vickey Rajpoot

Hello there! I'm dedicated Microsoft Data & AI Engineer at LTIMindtree, where I thrive technology into actionable insights. Dive into my world by visiting my YouTube channel & Webiste, "Kingfisher Tech Tips".

Articles: 96

Leave a Reply

Your email address will not be published. Required fields are marked *