
a.
“LENGTH” function:
- The “LENGTH()” function is used to return the length of a string that is return the number of characters in a given string.
- The syntax for “LENGTH()” function is
LENGTH(string)
- The parameter “string” implies the any string or any column name from specific table.
Example:
The example of “LENGTH()” function is given below:
CREATE TABLE STUDENT_NAMES(Student_ID integer PRIMARY KEY, Name text);
INSERT INTO STUDENT_NAMES VALUES(101,'John');
INSERT INTO STUDENT_NAMES VALUES(201,'Merry');
INSERT INTO STUDENT_NAMES VALUES(301,'Rose');
INSERT INTO STUDENT_NAMES VALUES(401,'Watson');
SELECT Name, LENGTH(Name) AS LengthOfName FROM STUDENT_NAMES;
Explanation:
The above query is used to display the length of each student name from “STUDENT_NAMES” table.
- User can create a table “STUDENT_NAMES” using “CREATE” and then insert the data into “STUDENT_NAMES” table using “INSERT” command.
- Using “SELECT” command, user can display the student name and its length.
- User can compute the length of each student name using “LENGTH” function.
- After that, the computed column is represented by “LengthOfName” with the help of “AS” operator.
When the query “SELECT Name, LENGTH(Name) AS LengthOfName FROM STUDENT_NAMES;” is executed, the following output will be displayed.
| Name | LengthOfName |
|--------|--------------|
| John | 4 |
| Merry | 5 |
| Rose | 4 |
| Watson | 6 |
“SUBSTR” function:
- The “SUBSTR()” function is used to extract a substring from a given string.
- The syntax for “SUBSTR()” function is
SUBSTR(sample_string, start_position, length)
- From the given syntax,
- The parameter “sample_string” implies the any string to extract from.
- The parameter “start_position” implies the starting position of given string.
- The parameter “length” implies number of characters to extract from the given string.
Example:
The example of “SUBSTR()” function is given below:
SELECT SUBSTR("Example SQL Query", 9, 3);
When the above query executed, the following output will be displayed.
Output: SQL
“INITCAP” function:
- The “INITCAP()” function is used to convert the first character of each word in the string to upper case character.
- The syntax for “INITCAP()” function is
INITCAP(sample_string)
- The parameter “sample_string” implies the any string.
Example:
The example of “INITCAP()” function is given below:
SELECT INITCAP('sample
Explanation:
- The above query is used to change the first letter of each word to upper case using “INITCAP” function.
- The computed column that is final result is represented by “Changed Word”.
- From the given query, the “DUAL” is a table which is automatically generated by Oracle
Database along with the data dictionary.- The “DUAL” table contains one column and one row. The column is defined to be “VARCHAR2(1)” and a row with a value “x”.
When the above query is executed, the following output will be displayed.
Output of the given Query:
| Changed String |
|--------------------|
| Sample Programming |
Three functions in Oracle, SQL Server and Access:
- “No”, the three functions are not same in SQL Server and access.
- Reasons for these condition.
- For Oracle:
- The functions “LENGTH”, “SUBSTR” and “INITCAP” are same for the Oracle.
- For SQL server:
- The function “LEN” is used to returns the length of the particular string.
- The “SUBSTRING” function is used to return a substring from a given string.
- The “INITCAP” function is not available in the SQL server.
- For Access:
- The function “LEN” is used to returns the length of the particular string.
- The “MID” function is used to return a substring from a given string.
- The “INITCAP” function is not available in Access.
- For Oracle:
Three functions in Oracle:
“LENGTH” function:
- The “LENGTH()” function is used to return the length of a string that is return the number of characters in a given string.
- The syntax for “LENGTH()” function is
LENGTH(string)
- The parameter “string” implies the any string or any column name from specific table.
Example:
The example of “LENGTH()” function is given below:
SELECT LENGTH('SQL Programming Concept') "Length of Characters" FROM DUAL;
Explanation:
- The above query is used to display the length of character from given string “'SQL Programming Concept” using “LENGTH” function.
- The computed column that is final result is represented by “Length of Characters”.
- From the given query, the “DUAL” is a table which is automatically generated by Oracle Database along with the data dictionary.
- The “DUAL” table contains one column and one row. The column is defined to be “VARCHAR2(1)” and a row with a value “x”.
When the above query is executed, the following output will be displayed.
Output of the given Query:
| Length of Characters |
|----------------------|
| 23 |
“SUBSTR” function:
- The “SUBSTR()” function is used to extract a substring from a given string.
- The syntax for “SUBSTR()” function is
SUBSTR(sample_string, start_position, length)
- From the given syntax,
- The parameter “sample_string” implies the any string to extract from.
- The parameter “start_position” implies the starting position of given string.
- The parameter “length” implies number of characters to extract from the given string.
Example:
The example of “SUBSTR()” function is given below:
SELECT SUBSTR('Example SQLQuery Result', 9, 8) "SubString" FROM DUAL;
Explanation:
- The above query is used to display the substring from the given string “'Example SQLQuery Result” using “SUBSTR” function.
- The computed column that is final result is represented by “SubString”.
- From the given query, the “DUAL” is a table which is automatically generated by Oracle Database along with the data dictionary.
- The “DUAL” table contains one column and one row. The column is defined to be “VARCHAR2(1)” and a row with a value “x”.
When the above query executed, the following output will be displayed.
Output of the given Query:
| SubString |
|-----------|
| SQLQuery |
“INITCAP” function:
- The “INITCAP()” function is used to convert the first character of each word in the string to upper case character.
- The syntax for “INITCAP()” function is
INITCAP(sample_string)
- The parameter “sample_string” implies the any string.
Example:
The example of “INITCAP()” function is given below:
SELECT INITCAP('sample programming') "Changed Word" FROM DUAL;
Explanation:
- The above query is used to change the first letter of each word to upper case using “INITCAP” function.
- The computed column that is final result is represented by “Changed Word”.
- From the given query, the “DUAL” is a table which is automatically generated by Oracle Database along with the data dictionary.
- The “DUAL” table contains one column and one row. The column is defined to be “VARCHAR2(1)” and a row with a value “x”.
When the above query is executed, the following output will be displayed.
Output of the given Query:
| Changed String |
|--------------------|
| Sample Programming |
Three functions in SQL Server:
“LEN” function:
- The “LEN()” function is used to return the length of a string that is return the number of characters in a given string.
- The syntax for “LEN()” function is
LEN(string)
- The parameter “string” implies the any string.
Example:
The example of “LEN()” function is given below:
SELECT LEN('SQL Programming Concept');
Explanation:
- The above query is used to display the length of character from given string “'SQL Programming Concept” using “LEN” function.
When the above query is executed, the following output will be displayed.
Output of the given Query:
23
“SUBSTRING” function:
- The “SUBSTRING()” function is used to extract a substring from a given string.
- The syntax for “SUBSTRING()” function is
SUBSTRING(sample_string, start_position, length)
- From the given syntax,
- The parameter “sample_string” implies the any string to extract from.
- The parameter “start_position” implies the starting position of given string.
- The parameter “length” implies number of characters to extract from the given string.
Example:
The example of “SUBSTR()” function is given below:
SELECT SUBSTRING('Example SQLQuery Result', 9, 8) AS SubString;
Explanation:
- The above query is used to display the substring from the given string “'Example SQLQuery Result” using “SUBSTRING” function.
- The computed column that is final result is represented by “SubString” with the help of “AS” operator.
When the above query executed, the following output will be displayed.
Output of the given Query:
SubString
SQLQuery
“INITCAP” function:
This function is not available in SQL server.
Three functions in Access:
“LEN” function:
- The “LEN()” function is used to return the length of a string that is return the number of characters in a given string.
- The syntax for “LEN()” function is
LEN(string/variable name)
- The parameter “string” implies the any string or any column name from specific table.
Example:
The example of “LEN()” function is given below:
SELECT LEN('SQL Programming Concept') AS Length_Of_String;
Explanation:
- The above query is used to display the length of character from given string “'SQL Programming Concept” using “LEN” function.
- The computed column that is final result is represented by “Length_Of_String” with the help of “AS” operator.
When the above query is executed, the following output will be displayed.
Output of the given Query:
Length_Of_String
23
“MID” function:
- The “MID()” function is used to extract a substring from a given string.
- The syntax for “MID()” function is
MID(sample_string, start_position, length)
- From the given syntax,
- The parameter “sample_string” implies the any string to extract from.
- The parameter “start_position” implies the starting position of given string.
- The parameter “length” implies number of characters to extract from the given string.
Example:
The example of “MID()” function is given below:
CREATE TABLE STUDENT_NAMES(Student_ID integer PRIMARY KEY, Name text);
INSERT INTO STUDENT_NAMES VALUES(301,'John Merry');
INSERT INTO STUDENT_NAMES VALUES(401,'Rose Lilly');
SELECT Name, MID(STUDENT_NAMES, 6, 5) AS SubString_Names FROM STUDENT_NAMES;
Explanation:
The above query is used to display the sub string each student name from “STUDENT_NAMES” table.
- User can create a table “STUDENT_NAMES” using “CREATE” and then insert the data into “STUDENT_NAMES” table using “INSERT” command.
- Using “SELECT” command, user can display the student name and its length.
- User can compute the sub string of each student name using “MID” function.
- After that, the computed column is represented by “SubString_Names” with the help of “AS” operator.
When the above query executed, the following output will be displayed.
Output of the given Query:
SubString_Names
Merry
Lilly
“INITCAP” function:
This function is not available in access.

Explanation of Solution
Oracle SQL query to display characters from the “TYPE” column in the “TRIP” table:
The Oracle SQL query to display three characters on the left from the “TYPE” column of the “TRIP” table is given below:
SELECT SUBSTR(TYPE,0,3) "SubString from TYPE Column" FROM TRIP;
Explanation:
The above query is used to display three characters on the left from the “TYPE” column of the “TRIP” table.
- Using “SUBSTR” function, user can display the three characters on the left from the “TYPE” column with three arguments “TYPE” column, start position “0” and number of character to extract “3”.
- The computed column is represented by “SubString from TYPE Column”.
- When the above query is executed, the following output will be displayed.
Screenshot of output:
Explanation of Solution
Oracle SQL query to display characters from the “START_LOCATION” column of the “TRIP” table:
The Oracle and SQL query for starting at the fourth character from the left, display the next five characters in the “START_LOCATION” column of the “TRIP” table is given below:
SELECT SUBSTR(START_LOCATION,4,5) "SubString of START_LOCATION" FROM TRIP;
Explanation:
The above query is used to display the given characters from “START_LOCATION” column of the “TRIP” table.
- Using “SUBSTR” function, user can display the given characters from the “START_LOCATION” column with three arguments “START_LOCATION” column, start position “3” and number of character to extract “5”.
- The computed column is represented by “SubString of START_LOCATION”.
- When the above query is executed, the following output will be displayed.

Screenshot of output:
Want to see more full solutions like this?
Chapter 8 Solutions
A Guide to SQL
- Python - need help creating a python program that will sum the digits of a number entered by the user. For example if the user inputs the value 243 the program will output 9 because 2 + 4 + 3 = 9. The program should ask for a single integer from the user, it should then calculate the sum of all the digits of that number and output the result.arrow_forwardI need help with this in Python (with flowchart): Im creating a reverse guessing game. Then to choose a random number from 1 to 100 and the computer program will attempt to guess it, displaying the directions calculated or not. The guess will be displayed and the user will answer if it was correct or not. If correct, the game ends, if not then the computer asks if the guess was too high or too low. Finally inputting an answer and the computer generates a new guess within the proper range. Oh and to make sure the program doesnt guess outside of the ranges produced by the inputs of “too high” and “too low”. The program ending when the user guesses correctly or after the program takes 6 guesses. HELP ASAP!arrow_forwardI need help with this in Python (with flowchart): Im creating a reverse guessing game. Then to choose a random number from 1 to 100 and the computer program will attempt to guess it, displaying the directions calculated or not. The guess will be displayed and the user will answer if it was correct or not. If correct, the game ends, if not then the computer asks if the guess was too high or too low. Finally inputting an answer and the computer generates a new guess within the proper range. Oh and to make sure the program doesnt guess outside of the ranges produced by the inputs of “too high” and “too low”. The program ending when the user guesses correctly or after the program takes 6 guesses. HELP ASAP!arrow_forward
- Need help finding errors in my pseudocode (Two)! Declare Boolean finished = False Declare Integer value, cube While NOT finished Display "Enter a value to be cubed." Input value; Set cube = value^3 Display value, " cubed is ", cube End While Next, I intended the following pseudocode to display the numbers 1 through 60, and then display the message "Time’s up!". Doesnt work and has error. Declare Integer counter = 1 Const Integer TIME_LIMIT = 60 While counter < TIME_LIMIT Display counter Set counter = counter + 1 End While Display "Time's up!"arrow_forwardHaving error in pseudcode; wanting to get five sets of two numbers each, calculate the sum of each set, and calculate the sum of all the numbers entered. Not functioning as intended and can't find the error.Code: // This program calculates the sum of five sets of two numbers. Declare Integer number, sum, total Declare Integer sets, numbers Constant Integer MAX_SETS = 5 Constant Integer MAX_NUMBERS = 2 Set sum = 0; Set total = 0; For sets = 1 To MAX_NUMBERS For numbers = 1 To MAX_SETS Display "Enter number ", numbers, " of set ", sets, "." Input number; Set sum = sum + number End For Display "The sum of set ", sets, " is ", sum "." Set total = total + sum Set sum = 0 End For Display "The total of all the sets is ", total, "."arrow_forwardNeed help converting loops!1. Convert the following While loop to a For loop: Declare Integer count = 0 While count < 50 Display "The count is ", count Set count = count + 1 End While _________________________________________________ 2. Convert the following For loop to a While loop: Declare Integer count For count = 1 To 50 Display count End Forarrow_forward
- Need help making this!1.Design a nested loop that displays 10 rows of # characters. There should be 15 # characters in each row. 2. Design a nested set of for loops that displays the following arrangements of ‘X’ characters X XX XXX XXXX XXXXX XXXXXXarrow_forwardI need help to resolve the case, thank youarrow_forwardIn 32-bit MSAM, You were given the following negative array. write a program that converts each array element to its positive representation. Then add all these array elements and assign them to the dl register. .data myarr sbyte -5, -6, -7, -4.code ; Write the rest of the program and paste the fully working code in the space below. the dl register should have the value 22 after summing up all elements in the array.arrow_forward
- Microprocessor 8085 Lab Experiment Experiment No. 3 Logical Instructions Write programs with effects 1. B=(2Dh XOR D/2) - (E AND 2Eh+1) when E=53, D=1Dh 2. HL= (BC+HL) XOR DE (use register pair when necessary), when BC=247, HL 516, DE 12Ach 3. Reset bits 1,4,6 of A and set bits 3,5 when A=03BH Write all as table (address line.hexacode,opcede,operant.comment with flags)arrow_forwardIn 32-bit MASM, Assume your grocery store sells three types of fruits. Apples, Oranges, and Mangos. Following are the sale numbers for the week (7 days).dataapples dword 42, 47, 52, 63, 74, 34, 73oranges dword 78, 53, 86, 26, 46, 51, 60mangos dword 30, 39, 41, 70, 75, 84, 29Using a single LOOP instruction, write a program to add elements in all these three arrays. Then assign the total result into the eax register. The eax register should have the value 1153 after a successful execution.arrow_forwardYou were given the following negative array. write a program that converts each array element to its positive representation. Then add all these array elements and assign them to the dl register. .data myarr sbyte -5, -6, -7, -4.code ; Write the rest of the program and paste the fully working code in the space below. The dl register should have the value 22 after summing up all elements in the array. Your answer must be in 32-bit MSAM.arrow_forward
- A Guide to SQLComputer ScienceISBN:9781111527273Author:Philip J. PrattPublisher:Course Technology PtrDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781305627482Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781285196145Author:Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos CoronelPublisher:Cengage Learning



