Beginning SQL

Beginning SQL Beginning SQL

marjan.fesb.hr
from marjan.fesb.hr More from this publisher
20.07.2013 Views

LocationId Street City State 1 Main Street Orange Town New State 2 Winding Road Windy Village Golden State 3 NULL NULL Mega State AnotherTable isn’t used again, so you can delete it from the database: DROP TABLE AnotherLocation; That’s it for INSERT INTO with SELECT for this chapter, though it returns in Chapter 8 when you learn about subqueries. Summary This chapter covered a number of topics relating to manipulating the results returned by SQL queries. Specifically you discovered that SQL has the basic four math functions dealing with addition, subtraction, multiplication, and division. Although SQL’s mathematical ability is fairly basic, it also includes a number of other math functions in addition to the fundamental four. These additional functions vary considerably among various database systems, but this chapter covered a few of the more common ones including the following: ❑ ABS(), which finds the absolute value of a number ❑ POWER(), which raises a number to a specified power (for example, squared means that a number is raised to the power of 2) ❑ SQRT(), which finds the square root of a number ❑ RAND(), which produces a fractional random number between 0 and 1 In addition to math functions, you learned that SQL also contains functions such as CEILING, FLOOR, and ROUND, which all deal with rounding up or down fractional numbers either to create a whole number or, in the case of ROUND, to reduce the number of decimal places. Furthermore, you learned that SQL has a number of functions that enable you to manipulate characterbased data. Each database system usually has a huge number of these functions, and this chapter covered the ones most commonly found in database systems including the following: ❑ SUBSTRING(), which allows you to extract part of a string from a larger string ❑ CASE() functions, which change the case of a string ❑ REVERSE(), which reverses the order of characters in a string ❑ LTRIM() and RTRIM() functions, which trim off spaces from the start or end of a string ❑ LENGTH(), which counts how many characters there are in a string Manipulating Data ❑ SOUNDEX() and DIFFERENCE() functions, which deal with matching based on how a word sounds rather than its exact spelling 187

LocationId Street City State<br />

1 Main Street Orange Town New State<br />

2 Winding Road Windy Village Golden State<br />

3 NULL NULL Mega State<br />

AnotherTable isn’t used again, so you can delete it from the database:<br />

DROP TABLE AnotherLocation;<br />

That’s it for INSERT INTO with SELECT for this chapter, though it returns in Chapter 8 when you learn<br />

about subqueries.<br />

Summary<br />

This chapter covered a number of topics relating to manipulating the results returned by <strong>SQL</strong> queries.<br />

Specifically you discovered that <strong>SQL</strong> has the basic four math functions dealing with addition, subtraction,<br />

multiplication, and division. Although <strong>SQL</strong>’s mathematical ability is fairly basic, it also includes a<br />

number of other math functions in addition to the fundamental four. These additional functions vary<br />

considerably among various database systems, but this chapter covered a few of the more common ones<br />

including the following:<br />

❑ ABS(), which finds the absolute value of a number<br />

❑ POWER(), which raises a number to a specified power (for example, squared means that a number<br />

is raised to the power of 2)<br />

❑ SQRT(), which finds the square root of a number<br />

❑ RAND(), which produces a fractional random number between 0 and 1<br />

In addition to math functions, you learned that <strong>SQL</strong> also contains functions such as CEILING, FLOOR,<br />

and ROUND, which all deal with rounding up or down fractional numbers either to create a whole number<br />

or, in the case of ROUND, to reduce the number of decimal places.<br />

Furthermore, you learned that <strong>SQL</strong> has a number of functions that enable you to manipulate characterbased<br />

data. Each database system usually has a huge number of these functions, and this chapter covered<br />

the ones most commonly found in database systems including the following:<br />

❑ SUBSTRING(), which allows you to extract part of a string from a larger string<br />

❑ CASE() functions, which change the case of a string<br />

❑ REVERSE(), which reverses the order of characters in a string<br />

❑ LTRIM() and RTRIM() functions, which trim off spaces from the start or end of a string<br />

❑ LENGTH(), which counts how many characters there are in a string<br />

Manipulating Data<br />

❑ SOUNDEX() and DIFFERENCE() functions, which deal with matching based on how a word<br />

sounds rather than its exact spelling<br />

187

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!