IBM DB2 Cloud Database and SQL : PART 3
In this article, I will walk you through some of the built-in functions in SQL to work on column values, followed by handling ‘dates’ values present in tables and finally we will work on nested selects and sub-queries. This article is continuation of my previous blog ‘IBM DB2 Cloud Database and SQL : PART 2’, link to which is given below.
In-order to perform mentioned operations, I have added 2 columns in CUSTOMER table, namely ‘ITEM_PRICE’ and ‘ORDER_DATE’ to hold the information of checkout price and the date at which ordered was placed. You can add new columns in tables using command ‘ALTER TABLE’ as,
Syntax-
ALTER TABLE table_name ADD column_name datatype;
Using above SQL command, I have added new column ‘ORDER_DATE’ with the datatype of ‘DATE’ into CUSTOMER table. Similarly, you can add column to hold price as well. Then using UPDATE command you can insert the relevant data into respective columns. As an example, I have provided SQL command to update price and date for customer with ID =14.
More on UPDATE statement has been discussed in Part 1 of this blog series, which you can revisit through below link.