{"id":2211,"date":"2020-01-23T02:42:34","date_gmt":"2020-01-23T02:42:34","guid":{"rendered":"http:\/\/kusuaks7\/?p=1816"},"modified":"2024-01-24T17:30:27","modified_gmt":"2024-01-24T17:30:27","slug":"understanding-sqls-application-in-data-science-a-deep-dive","status":"publish","type":"post","link":"https:\/\/www.experfy.com\/blog\/bigdata-cloud\/understanding-sqls-application-in-data-science-a-deep-dive\/","title":{"rendered":"Understanding SQL&#8217;s Application in Data Science [A Deep Dive]"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"2211\" class=\"elementor elementor-2211\" data-elementor-post-type=\"post\">\n\t\t\t\t\t\t<section class=\"has_eae_slider elementor-section elementor-top-section elementor-element elementor-element-1aa4d531 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"1aa4d531\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"has_eae_slider elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-bbead00\" data-id=\"bbead00\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-af29346 elementor-widget elementor-widget-heading\" data-id=\"af29346\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h3 style=\"color: #aaa;font-style: italic\">To learn about SQL, we need to understand how a DBMS works. DBMS or Database Management System is essentially a software to create and manage databases.<\/h3><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-04f2f83 elementor-widget elementor-widget-text-editor\" data-id=\"04f2f83\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tIt will be useful to know why and how SQL holds such an important stature in the field of data science.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b402e03 elementor-widget elementor-widget-heading\" data-id=\"b402e03\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2><strong>What is data science?<\/strong><\/h2><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-494d13f elementor-widget elementor-widget-text-editor\" data-id=\"494d13f\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tData science is a field that uses many scientific methods and processes to collect data and get useful insights from them. Doing this creates new opportunities, designs, business cases and even revolutionary innovations.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-41af1b7 elementor-widget elementor-widget-text-editor\" data-id=\"41af1b7\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tThe future of AI lies in Data science. Data science involves use of algorithms, software programs and statistics to collate and process huge complex chunks of data. The complexity of data comes from its unstructured nature \u2013 data today can be in any form \u2013 text, image, output from sensors and instruments and what not!\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-652b10d elementor-widget elementor-widget-text-editor\" data-id=\"652b10d\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tAs of today, the benefits of data science can be felt in domains like e-commerce, healthcare, manufacturing, banking, finance and transport.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9377fc5 elementor-widget elementor-widget-heading\" data-id=\"9377fc5\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2><strong>The Basics of DBMS and Relational Database<\/strong><\/h2><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f02e229 elementor-widget elementor-widget-text-editor\" data-id=\"f02e229\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tTo learn about SQL, we need to understand how a DBMS works. DBMS or Database Management System is essentially a software to create and manage databases. With DBMS, programmers can create, manage or select data.\n<blockquote>Database acts as an interface between end users and application programs to access data in an organized and consistent manner. For example, a user logs in to Facebook.<\/blockquote>\nBased on the user\u2019s registered email address and password, API calls are made from the application to the database and user details are retrieved.\n<blockquote>In a relational DBMS or RDBMS, SQL is the API through which users and applications access data. Data can be accessed in the form of tables and its columns.<\/blockquote>\nThe relationships between the tables is such that there is no need to reorganize the data or the tables. Using SQL statements, we can get information about multiple tables and their relationships.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-cbf1439 elementor-widget elementor-widget-heading\" data-id=\"cbf1439\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2><strong>What is SQL?<\/strong><\/h2><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-c82ecfc elementor-widget elementor-widget-text-editor\" data-id=\"c82ecfc\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tSQL or Structured Query Language is a \u2018programming language\u2019 that manages data in a relational database through \u2018queries\u2019. By using SQL, we can insert, update, delete and select data based on various filters and conditions. SQL also helps run certain scheduled scripts automatically, that need to run regularly.\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-61b3e2c elementor-widget elementor-widget-text-editor\" data-id=\"61b3e2c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tWith SQL, Developers and data analysts can easily code and run queries. For example, select * from customer; is a simple query that gives details of the customer table.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7eef5fa elementor-widget elementor-widget-text-editor\" data-id=\"7eef5fa\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\nAnalysts can access huge amounts of data, process it without having to copy or store data anywhere else.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-682666e elementor-widget elementor-widget-text-editor\" data-id=\"682666e\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tIt is easy to analyze data using SQL queries than using excel sheets or any other methods. There are a lot of aggregation functions in SQL that can work on large datasets and multiple tables.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-964c830 elementor-widget elementor-widget-heading\" data-id=\"964c830\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2><strong>Understanding the lifecycle of data science<\/strong><\/h2><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d0a8105 elementor-widget elementor-widget-text-editor\" data-id=\"d0a8105\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tTo understand how SQL is used in data science, we need to know the different phases of data science.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-df5acf3 elementor-widget elementor-widget-text-editor\" data-id=\"df5acf3\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tThere are 3 important phases in the lifecycle of Data Science \u2013\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-61171cd elementor-widget elementor-widget-heading\" data-id=\"61171cd\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2><strong>1. Data conditioning and cleaning<\/strong><\/h2><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d227e35 elementor-widget elementor-widget-text-editor\" data-id=\"d227e35\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tAfter discovery of data from various sources, data has to be prepared and structured. That means, all the redundant and duplicate data should be removed and a neat structure should be formed so that it is easy to model the data. This is called\u00a0<a href=\"https:\/\/hackr.io\/blog\/dbms-normalization\" rel=\"noopener\">DBMS normalization<\/a>\u00a0and all relational databases follow this approach.\n<blockquote>With SQL, structuring and conditioning of the data can be done easily because SQL has the concept of primary key and constraints, wherein the redundancy and dependency can be removed and proper relationship can be established between different data types.<\/blockquote>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2e37ea1 elementor-widget elementor-widget-text-editor\" data-id=\"2e37ea1\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tSQL can also help with data cleaning, which means irrelevant, incorrect or corrupt records can be removed periodically by automatic batch scripts without any manual intervention. You can also use R for data cleaning and transformation, however using SQL in conjunction with R can reduce the amount of code to be written and bring in more flexibility.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-985cbec elementor-widget elementor-widget-heading\" data-id=\"985cbec\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2><strong>2. Data modelling and mining<\/strong><\/h2>\n<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-563a7bc elementor-widget elementor-widget-text-editor\" data-id=\"563a7bc\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tModel planning and building totally relies on DBMS (Database Management Systems), particularly Structured query Language or SQL (if you did not know it already!). Big data is a big chunk of unstructured data and only a structured language can save our time trying to establish relationships between the variables of presented data.\n<blockquote>A simple example of modelling will be a customer who is trying to purchase a postpaid mobile connection with a plan, subscription and a few value-added services.<\/blockquote>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-782ddb6 elementor-widget elementor-widget-text-editor\" data-id=\"782ddb6\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tEach of these can be a table in the relational DBMS and the relationship between them can be established using a common key like the customer_id, phone_number or subscription_id which can be unique. Thus, we are creating entities (tables), attributes (columns), relationships (customer_id linked to subscription_id or phone_number etc\u2026) and integrities (customer_id should be unique, phone_number and subscription_id together can be a composite key and so on).\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d8ccafe elementor-widget elementor-widget-text-editor\" data-id=\"d8ccafe\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<blockquote>We can also create triggers, for example, whenever the customer changes any value-added services, a trigger enables the service to be activated automatically after performing the necessary eligibility checks.<\/blockquote>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-46dba1c elementor-widget elementor-widget-text-editor\" data-id=\"46dba1c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tData mining is a process where huge sets of data is examined for patterns and trends for evaluating data to solve a business purpose. The process becomes easier when large datasets are organized and structured.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ca4066a elementor-widget elementor-widget-text-editor\" data-id=\"ca4066a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\nAs a continuation, let us say we want to identify what are the value-added services that most users are interested in. Since every person nowadays has at least one mobile phone and the number of services that can be added are unlimited, this will be a huge data to consolidate, sort and examine.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-56e969b elementor-widget elementor-widget-text-editor\" data-id=\"56e969b\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tSQL makes things easier by giving particular records based on specific user query. For example, if we want to know the users who have activated \u2018ringtone\u2019 services during calls, we can write a query as \u2013\n<pre><code>select customer_id from value_added_service table where service = \u2018ringtone\u2019 and is_service_enabled = \u2018Y\u2019 and service_end_date &gt; NOW();\n<\/code><\/pre>\nFor complex queries indexing can be done to fetch results faster.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9d68740 elementor-widget elementor-widget-text-editor\" data-id=\"9d68740\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tWe can also use in-built SQL functions to list the data in ascending order based on service_end_date, group by a certain order and so on.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-4b16ff0 elementor-widget elementor-widget-heading\" data-id=\"4b16ff0\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2><strong>SQL basics for Data Analysis<\/strong><\/h2><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d547060 elementor-widget elementor-widget-text-editor\" data-id=\"d547060\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tYou might want to argue that excel sheet with huge amount of data can also fetch the results and do some filtering operations as well. It is true, but not comparable to the scale at which SQL stores its data. But how much SQL is enough for you to be a data scientist?\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-15feb11 elementor-widget elementor-widget-text-editor\" data-id=\"15feb11\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<blockquote>There is no definite answer, however we have tried to squeeze in a lot of information that will help you grasp the basic idea. If you already know SQL, you will be familiar with most of it, if you are not, don\u2019t worry, this blog will give you good insights of the basics.<\/blockquote>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f0d8326 elementor-widget elementor-widget-text-editor\" data-id=\"f0d8326\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tMost of the time, the database and schema will be already present with all the relationships established. As a data scientist, you will need to understand the schema, relationships and how you can query the database to get the best of the results from a business perspective.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-27dee38 elementor-widget elementor-widget-text-editor\" data-id=\"27dee38\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tLet us create some data and then work our way to fetch this data using the different techniques we will learn below.\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-91158a8 elementor-widget elementor-widget-text-editor\" data-id=\"91158a8\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tBelow are the most important statements and commands that you will use on a daily basis.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-640233a elementor-widget elementor-widget-text-editor\" data-id=\"640233a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\nSelecting rows and columns\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ff519a1 elementor-widget elementor-widget-text-editor\" data-id=\"ff519a1\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tThe basic query that fetches all the data from a table is \u2013\n<pre><code>select * from table_name;\n<\/code><\/pre>\nLet us get some records from student table.\nDoing\n<pre><code>select * from student;\n<\/code><\/pre>\nwill fetch us all the rows and columns present in the table.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-efbf06e elementor-widget elementor-widget-text-editor\" data-id=\"efbf06e\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tDoing\n<pre><code>select * from student;\n<\/code><\/pre>\nwill fetch us all the rows and columns present in the table.\n\nWhat if we only wanted the first name and the date of birth? Then we should specify the column names in the query.\n<pre><code>select first_name, date_of_birth from student;\n<\/code><\/pre>\n<strong>first name\u00a0 date_of_birth<\/strong>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-\nMaria \u00a0 \u00a0 \u00a0 17-11-1984\nGopal \u00a0 \u00a0 \u00a0 04-02-1983\nKeshav\u00a0 \u00a0 \u00a0 14-12-1983\nAaron \u00a0 \u00a0 \u00a0 05-03-1984\nNaman \u00a0 \u00a0 \u00a0 06-06-1984\n\nWe can also use some expressions to display the data in a particular way. For example,\n<pre><code>select first_name + \u2018 \u2018 + last_name as full_name from student;\n<\/code><\/pre>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-a80ae37 elementor-widget elementor-widget-text-editor\" data-id=\"a80ae37\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tYou will get something like \u2013\n\n<strong>full_name<\/strong>\n&#8212;&#8212;&#8212;&#8212;\nMaria Thomas\nGopal Chandra\nKeshav Sharma\nAaron V\nNaman K\n\nFiltering rows based on conditions\n\nMost of the times, we need only particular trends and patterns. These patterns can be our filters, based on which we will get only those records from database which are relevant and satisfy our conditions. For example,\n\nIf we want to get students of the teacher Brunda only, we can use a where clause.\n<pre><code>select first_name, date_of_birth from student where teacher_name = \u2018Brunda\u2019;<\/code><\/pre>\nIt is also easy and efficient to use grouping and sorting functions. To start with, if we want to group the records based on the deptt, we can add a group by clause \u2013\n<pre><code>select first_name, date_of_birth from student where adm_year = 2001 group by deptt;\n<\/code><\/pre>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-dda9553 elementor-widget elementor-widget-text-editor\" data-id=\"dda9553\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<\/code><\/pre>\n\u2018Having\u2019 is another filter similar to the where clause which we can apply on group functions. For example, we want to have all the records of ECE dept with admission date after 2001, we can write the query as \u2013\n<pre><code>select first_name, deptt, date_of_birth from student group by deptt having adm_year &gt; 2001;<\/code><\/pre>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-528faa4 elementor-widget elementor-widget-text-editor\" data-id=\"528faa4\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tThis will fetch something like \u2013\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3e35876 elementor-widget elementor-widget-text-editor\" data-id=\"3e35876\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<strong>first_name \u00a0 deptt date_of_birth<\/strong>\nMaria \u00a0 ECE \u00a0 \u00a0 \u00a0 17-11-1984\nNaman \u00a0 ECE\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 06-06-1984\nKeshav \u00a0 CSE\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 14-12-1983\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-c3642d5 elementor-widget elementor-widget-text-editor\" data-id=\"c3642d5\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tIt can so happen that there may be similar records and we want to get only one of them. For example, the deptt (departments) column. If we want to list all the departments present in the database, we can use the keyword distinct. This will give all the unique values in the column.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-102af1d elementor-widget elementor-widget-text-editor\" data-id=\"102af1d\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tSame way, we can get the count of students based on certain conditions, find sum, average, find records that have a particular date of birth and many more things.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-31a331c elementor-widget elementor-widget-heading\" data-id=\"31a331c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2><strong>Aggregating results using in-built functions<\/strong><\/h2><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-6df1229 elementor-widget elementor-widget-text-editor\" data-id=\"6df1229\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tAggregate functions are used with group by, having clause to get a scalar value from a select statement. The most common functions are \u2013 SUM, AVG, COUNT, MAX, MIN. Except count function, all others ignore a NULL value. In the above example, if we want to get count of students in ECE deptt, we can form a query as \u2013\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7d35f44 elementor-widget elementor-widget-text-editor\" data-id=\"7d35f44\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<pre><code>select count(*) from student where deptt = \u2018ECE\u2019;<\/code><\/pre>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-5580f28 elementor-widget elementor-widget-text-editor\" data-id=\"5580f28\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tSimilarly, if we want to get the average percentage obtained by CSE students of all grades, we can use the AVG function and so on.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3615883 elementor-widget elementor-widget-heading\" data-id=\"3615883\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2><strong>Joins<\/strong><\/h2><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-0ebe90d elementor-widget elementor-widget-text-editor\" data-id=\"0ebe90d\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tA relational database, as we know has multiple small tables that can be mapped to each other. To obtain data from multiple tables in a single result, we join the tables and display the required columns. There are different types of joins \u2013\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-c2d4fbf elementor-widget elementor-widget-text-editor\" data-id=\"c2d4fbf\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<ul>\n \t<li>Left join<\/li>\n \t<li>Right join<\/li>\n \t<li>Outer join<\/li>\n \t<li>Inner join<\/li>\n \t<li>Self-join<\/li>\n \t<li>Cross join<\/li>\n<\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f2693c7 elementor-widget elementor-widget-text-editor\" data-id=\"f2693c7\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tIf you would like to get into details of each or any of the above, this interactive course caters to all the SQL that is required for you to be a data scientist and all that we have discussed above.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-5ad3ccd elementor-widget elementor-widget-heading\" data-id=\"5ad3ccd\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2><strong>SQL Analysis services<\/strong><\/h2><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-475707d elementor-widget elementor-widget-text-editor\" data-id=\"475707d\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tMicrosoft has come up with a nice tool that a lot of organizations use to analyze the huge data spread across multiple databases. Abbreviated as SSAS, this online analytical processing and data mining tool includes a lot of services like modeling, integration, reporting and analysis. For more information, check the information from the official microsoft page\u00a0<a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/analysis-services\/analysis-services?view=sql-server-2017\" rel=\"noopener\">here<\/a>.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9b73230 elementor-widget elementor-widget-heading\" data-id=\"9b73230\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\"><h2><strong>The final word<\/strong><\/h2><\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2d4c10a elementor-widget elementor-widget-text-editor\" data-id=\"2d4c10a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\tThere are many sub fields in data science, but irrespective of that, SQL remains an important ingredient in the Data science dish. Without the essence of SQL, your entry into this field would be incomplete. Learning and implementing SQL will go a long way in helping you think of more creative ideas and turn your data into useful business use cases or insights.\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>There are many sub fields in data science, but irrespective of that, SQL remains an important ingredient in the Data science. It will be useful to know why and how SQL holds an important stature in the field of data science.&nbsp;Without the essence of SQL, your entry into this field would be incomplete. Learning and implementing SQL will go a long way in helping you think of more creative ideas and turn your data into useful business use cases or insights.<\/p>\n","protected":false},"author":714,"featured_media":3446,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"content-type":"","footnotes":""},"categories":[187],"tags":[94],"ppma_author":[3532],"class_list":["post-2211","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bigdata-cloud","tag-data-science"],"authors":[{"term_id":3532,"user_id":714,"is_guest":0,"slug":"vijay-singh-khatri","display_name":"Vijay Khatri","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g","user_url":"","last_name":"Khatri","first_name":"Vijay","job_title":"","description":"Vijay Singh Khatri is Sr. Digital Marketing Manager at Squareboat."}],"_links":{"self":[{"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/posts\/2211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/users\/714"}],"replies":[{"embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/comments?post=2211"}],"version-history":[{"count":4,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/posts\/2211\/revisions"}],"predecessor-version":[{"id":35637,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/posts\/2211\/revisions\/35637"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/media\/3446"}],"wp:attachment":[{"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/media?parent=2211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/categories?post=2211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/tags?post=2211"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=2211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}