SQL TO_CHAR Function The Best DATE Example

Here’s an example of SQL TO_CHAR function. Here, I’ve explained how to use this function correctly.

How to Use SQL TO_CHAR to Convert DATE to CHAR

Create View Order_V5 AS
SELECT    Ord_Number, Cust_Number
 ,TO_CHAR(Order_Date , 'MON, DD, YYYY') AS Order_Date
 ,TO_CHAR(Order_Total, '999,999.99') AS Total
FROM Order_Table ;

Query Result

Ord_NumberCust_NumberOrder_DateTotal
12345622222222MAY, 04, 200012,347.53
12351255555555JAN, 01, 20018,005.91
12355231323134OCT, 01, 20025,111.47
12358587323456OCT, 10, 200315,231.62
12377757896883SEP, 09, 199923,454.84

SQL Views and its Advanatges

A view is SQL query of primary need is to protect BASE TABLE data. The view can be created with or without ORDER BY clause.

  1. A view is a virtual table
  2. A view may define a subset of columns
  3. A view can even define a subset of rows if it has a WHERE clause
  4. A view never duplicates data or stores the data separately
  5. Views provide security
  6. An additional level of security is provided
  7. Helps the business user not miss join conditions
  8. Help control read and update privileges
  9. Unaffected when new columns are added to a table
  10. Unaffected when a column is dropped unless it’s referenced in the view

Related Posts

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.