tailieunhanh - Joe Celko s SQL for Smarties - Advanced SQL Programming P68

Joe Celko s SQL for Smarties - Advanced SQL Programming P68. In the SQL database community, Joe Celko is a well-known columnist and purveyor of valuable insights. In Joe Celko's SQL for Smarties: Advanced SQL Programming, he picks up where basic SQL training and experience leaves many database professionals and offers tips, techniques, and explanations that help readers extend their capabilities to top-tier SQL programming. Although Celko denies that the book is about database theory, he nevertheless alludes to theory often to buttress his practical points. This title is not for novices, as the author points out. Instead, its intended. | 642 CHAPTER 29 TEMPORAL QUERIES 1 hens 11 2 days rate 1 egg multiply by eggs per hen 11 2 days rate 1 egg per hen divide by the number of hens rate egg per hen per day divide by 11 2 days If you still do not get it draw a graph. Temporal Math Almost every SQL implementation has a DATE data type but the functions available for that data type vary quite a bit. The most common ones are a constructor that builds a date from integers or strings extractors to pull out the month day or year and some display options to format output. You can assume that your SQL implementation has simple date arithmetic functions although with different syntax from product to product such as 1. A date plus or minus a number of days yields a new date 2. A date minus a second date yields an integer number of days Table shows the valid combinations of datetime and interval data types in Standard SQL Table Valid Combinations of Temporal Data Types in Standard SQL datetime - datetime interval datetime interval datetime interval or numeric interval interval datetime datetime interval interval interval numeric interval interval Personal Calendars 643 Other rules dealing with time zones and the relative precision of the two operands are intuitively obvious. There should also be a function that returns the current date from the system clock. This function has a different name with each vendor TODAY SYSDATE NOW CURRENT DATE and getdate are some examples. There may also be a function to return the day of the week from a date which is sometimes called dow or weekday . Standard SQL provides for CURRENT_ DATE CURRENT_TIME time precision and CURRENT_TIMESTAMP timestamp precision functions which are self-explanatory. Personal Calendars One of the most common applications of dates is to build calendars that list upcoming events or actions to be taken by their user. People have no trouble with using a paper calendar to trigger their own actions but the idea of having an internal .