Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

SQL Exercises: Salesmen commission with the percent sign ( % )

SQL Formatting Output: Exercise-1 with Solution

From the following table, write a SQL query to select all the salespeople. Return salesman_id, name, city, commission with the percent sign (%).

Sample table: salesman


Sample Solution:

SELECT salesman_id,name,city,'%',commission*100 
FROM salesman;

Output of the Query:

salesman_id	name		city		?column?	?column?
5001		James Hoog	New York	%		15.00
5002		Nail Knite	Paris		%		13.00
5005		Pit Alex	London		%		11.00
5006		Mc Lyon		Paris		%		14.00
5007		Paul Adam	Rome		%		13.00
5003		Lauson Hen	San Jose	%		12.00

Relational Algebra Expression:

Relational Algebra Expression: Salesmen commission with the percent sign ( % ).

Relational Algebra Tree:

Relational Algebra Tree: Salesmen commission with the percent sign ( % ).

Explanation:

SQL Subqueries: Find all customers with orders on October 5, 2012.

Explanation:

Syntax of display the commission with the percent sign

Pictorial presentation :

Result of display the commission with the percent sign

Practice Online


Query Visualization:

Duration:

Query visualization of Salesmen commission with the percent sign ( % ) - Duration

Rows:

Query visualization of Salesmen commission with the percent sign ( % ) - Rows

Cost:

Query visualization of Salesmen commission with the percent sign ( % ) - Cost

 

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: SQL Formatting Output Exercises Home
Next: From the following table, write a SQL query to find the number of orders booked for each day. Return the result in a format like "For 2001-10-10 there are 15 orders".

Test your Programming skills with w3resource's quiz.

What is the difficulty level of this exercise?



SQL: Tips of the Day

SQL Server SELECT into existing table.

INSERT INTO dbo.TABLETWO
SELECT col1, col2
  FROM dbo.TABLEONE
 WHERE col3 LIKE @search_key

This assumes there's only two columns in dbo.TABLETWO - you need to specify the columns otherwise:

INSERT INTO dbo.TABLETWO
  (col1, col2)
SELECT col1, col2
  FROM dbo.TABLEONE
 WHERE col3 LIKE @search_key

Database: SQL Server

Ref: https://bit.ly/3y6tpA3