Here is an example:
Using the AND operator in the WHERE clause to get a value from both tables each, as shown in query below:
Inserting date in Oracle table, for doing that we need to use the TO_DATE function like: TO_DATE('12/01/2016', 'DD/MM/YYYY'), as shown in example below:
Then SELECT for a specific DATE as given below:
----------------------------------------------------------------------------------------------------------------------
To get 'weekly' data (sum/count) :
suppose there is a 'sales' table having a 'sold_date' field, then
SELECT product_name, SUM(price) FROM sales WHERE sold_date <= (sysdate) AND sold_date >= (sysdate - 7);
Similarly for generating Monthly reports
SELECT product_name, SUM(price) FROM sales WHERE sold_date <= (sysdate) AND sold_date >= (sysdate - 30);
-------------------------------------------------------------------------------------------------------------
We can have multiple AND operator in a SQL query
-----------------------------------------------------------------------------------------------------------
Understanding SQL Transactions
-----------------------------------------------------------------------------------------------------------
You can PRINT text in Oracle using AS clause:
Using the AND operator in the WHERE clause to get a value from both tables each, as shown in query below:
Inserting date in Oracle table, for doing that we need to use the TO_DATE function like: TO_DATE('12/01/2016', 'DD/MM/YYYY'), as shown in example below:
Then SELECT for a specific DATE as given below:
----------------------------------------------------------------------------------------------------------------------
To get 'weekly' data (sum/count) :
suppose there is a 'sales' table having a 'sold_date' field, then
SELECT product_name, SUM(price) FROM sales WHERE sold_date <= (sysdate) AND sold_date >= (sysdate - 7);
Similarly for generating Monthly reports
SELECT product_name, SUM(price) FROM sales WHERE sold_date <= (sysdate) AND sold_date >= (sysdate - 30);
-------------------------------------------------------------------------------------------------------------
We can have multiple AND operator in a SQL query
-----------------------------------------------------------------------------------------------------------
Understanding SQL Transactions
-----------------------------------------------------------------------------------------------------------
You can PRINT text in Oracle using AS clause:
No comments:
Post a Comment