The Language of SQL- P12

The Language of SQL- P12:Research has shown that, being pressed for time, most readers tend to skip the introduction of any book they happen to read and then proceed immediately to the first real chapter. With that fact firmly in mind, we will only cover relatively unimportant material in the introduction, such as an explanation of what you will and will not learn by reading this book. | Conversion Functions 41 be used. If it s not used then the RAND function returns a random value between 0 and 1. If executed 10 times in a row it will return 10 different values. It looks like SELECT RAND AS Random Value If the seed argument is specified it needs to be an integer value. When the RAND function is executed with a seed argument provided it will return the same value every time. It might look like SELECT RAND 10 0 AS Random Value When you change the value of the seed argument it will return a different value. The PI function merely returns the value of the mathematical number pi. Think back to your days in geometry class. In reality this function is very seldom used but it nicely illustrates the point that numeric functions need not have any arguments. For example the statement SELECT PI returns the value DATABASE DIFFERENCES Oracle Oracle doesn t have functions comparable to rand or pi. What if you wanted the value of pi rounded to only two decimal places Simple. You merely create a composite function with the PI and ROUND functions. You would first use the PI function to get the initial value and then apply the ROUND function to round it to two decimal places. The following statement returns a value of SELECT ROUND PI 2 Conversion Functions All of the aforementioned functions relate to specific ways to manipulate character date time or numeric datatypes. But you may need to convert data from 42 Chapter 4 Using Functions one datatype to another or convert NULL values to something meaningful. The remainder of this chapter will cover two special functions that can be used in these situations. The CAST function allows you to convert data from one datatype to another. The general format of the function is CAST Expression AS DataType The CAST function is actually unnecessary in many situations. Let s take the situation where you want to execute this statement where the Quantity column is defined as a character column SELECT 2 Quantity

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
204    102    3    02-07-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.