admin

MySQL Query to find the age of a person whose date of birth is stored in a column called “dob” in a table called “persons”

SELECT TIMESTAMPDIFF(YEAR, dob, CURDATE()) AS age FROM persons; This query will return the age in years. If you want to get the age in months or days, you should use MONTH or DAY instead of YEAR in TIMESTAMPDIFF function. To get the age in months:SELECT TIMESTAMPDIFF(MONTH, dob, CURDATE()) AS age FROM persons; To get the […]

MySQL Query to find the age of a person whose date of birth is stored in a column called “dob” in a table called “persons” Read More »

SQL for BI – Joins in SQL

Table: table_a id 1 1 1 4 5 Table: table_b id 1 1 2 3 6 SQL Code to create table and insert data USE sqlforbi; CREATE TABLE `table_a` ( `id` int NOT NULL ); CREATE TABLE `table_b` ( `id` int NOT NULL ); insert into table_a values (1); insert into table_a values (1); insert

SQL for BI – Joins in SQL Read More »

SQL for BI – Orders table

Table: orders order_id cust_id order_date ship_date payment_mode created_date 10001 1 2022-01-15 22:15:00 2022-01-16 09:15:00 Credit Card 15/01/22 10002 1 2022-01-24 04:15:43 2022-01-26 15:00:15 Net Banking 24/01/22 10003 4 2022-01-30 08:15:32 2022-01-30 13:15:00 Cash on Delivery 30/01/22 10004 5 2022-02-13 21:20:00 2022-02-17 14:09:10 Credit Card 13/02/22 10005 3 2022-02-14 18:00:14 2022-02-14 18:10:10 Credit Card 14/02/22 SQL

SQL for BI – Orders table Read More »

Practice

Task 1: Download “Sample Superstore 2022 – Excel data” file from here 1. Connect to the data source 2. Change the name of field “Product name” to “Product Description” 3. Change the data role for the “Order Date” field to Date && Time

Practice Read More »

SQL

What is SQL? Acronym SQL stands for Structured Query Language used to communicate between you and the database. Data is stored in the database in the form of tables. SQL is used to Write data in a database Read (query) data stored in a database Update and insert new data Syntax for SQL depends on

SQL Read More »