<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tanmoy Banerjee on Medium]]></title>
        <description><![CDATA[Stories by Tanmoy Banerjee on Medium]]></description>
        <link>https://medium.com/@tanmoywork23?source=rss-9e6f81c3b5d9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FUGrQVTRmRXxhhFVK-UIGA.jpeg</url>
            <title>Stories by Tanmoy Banerjee on Medium</title>
            <link>https://medium.com/@tanmoywork23?source=rss-9e6f81c3b5d9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 18:07:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tanmoywork23/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Power BI]]></title>
            <link>https://medium.com/@tanmoywork23/power-bi-fca79faa93c4?source=rss-9e6f81c3b5d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/fca79faa93c4</guid>
            <category><![CDATA[power-bi]]></category>
            <category><![CDATA[power-bi-tutorials]]></category>
            <category><![CDATA[power-bi-desktop]]></category>
            <category><![CDATA[power-bi-training]]></category>
            <category><![CDATA[power-bi-step-by-step]]></category>
            <dc:creator><![CDATA[Tanmoy Banerjee]]></dc:creator>
            <pubDate>Tue, 23 May 2023 06:39:36 GMT</pubDate>
            <atom:updated>2023-05-23T06:39:36.844Z</atom:updated>
            <content:encoded><![CDATA[<h4>by ( Tanmoy Banerjee )</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*cRqqU_ccQuBnP9OnBWFrsg.gif" /></figure><p>Power BI is a “<strong>MICROSOFT</strong>” specific product.</p><p><strong>Data plays a major role in daily life. This data residing in any system is useless if it has no ability to communicate or to interpret. In order to obtain meaningful information from the underlying data Business Intelligence tools come into the picture</strong>.</p><p>Microsoft Power BI is one of the powerful Business Intelligence tools. It is a collection of software services and apps that can be connected together to converts unrelated data into meaningful insight. Data can be lying in excel, server, csv, databases or in any warehouse. Power BI lets analysts connect to such hybrid sources, clean and model without affecting data from source and visualize important attributes and share insights.</p><h3>### Power BI Usage Types</h3><p>Power BI is a complete BI suite that majorly comprises a Windows desktop application called <strong>Power BI Desktop</strong>, an online SaaS (Software as a Service) service called Power BI Service, and mobile Power BI apps for iOS and Android devices.</p><p>Power BI consists of several elements that all work together, one can make use of the complete suite. Different offerings from Microsoft -</p><h3><strong>###Power BI Desktop</strong></h3><p>Free, a standalone application intended for small to midsize businesses</p><h3>###Power BI Service</h3><ul><li><strong>Power BI Pro</strong> — Paid per-user license, needed to get access to advanced features and the ability to share reports</li><li><strong>Power BI Premium</strong> — Licenses by scale, intended for large businesses and enterprises</li><li><strong>Power BI Mobile</strong> — Device-based app for phones and tablets</li><li><strong>Power BI Embedded </strong>— A white-label version of Power BI which Independent Software Vendors can embed in their own apps, rather than build their own analytical features</li><li><strong>Power BI Report Server </strong>— An on-premise version of the Power BI Desktop app for businesses that need to keep their data and reports on their own servers</li></ul><h3>Users of Power BI</h3><p>How you use Power BI may depend on your role in a project or on a team. There is a lot of flexibility and variations in Power BI usage. How you use Power BI can be based on which feature or service of Power BI is the best tool for your situation. Each part of Power BI is available to you, which is why it’s so flexible and compelling.</p><ul><li>Power BI for <strong>business users</strong>.</li><li>Power BI Desktop for <strong>report creators</strong>.</li><li>Power BI Report <strong>Builder for enterprise</strong>.</li><li>Power BI for <strong>administrators</strong>.</li><li>Power BI for <strong>developers</strong>.</li></ul><p>The free version of Power BI Desktop is also available for students for learning and working on academic projects.</p><h3>Components of Power BI</h3><p>Power BI Desktop and service contain powerful utility-based components that define the workflow of data inside the BI tool. -</p><p><strong>Power Query</strong>: <em>A data connection component that lets you transform, combine, and preprocess the data from several sources</em></p><p><strong>Power Pivot /Data Modelling</strong>: <em>A data modeling tool for creating data models i.e. schemas and relationships within different tables and attributes.</em></p><p><strong>Power View</strong>: <em>The data visualization canvas that holds various interactive charts, graphs, maps, and other visuals.</em></p><p><strong>Power Q&amp;A:</strong> <em>A recent addition, which is a question and answer engine that lets you ask questions about your data in plain language.</em></p><h3><em>Data connections</em></h3><p>With Power BI Desktop, you can connect to data from many different sources. The wide variety of connections possible over 200 can be broadly categorized as -</p><h4>File — Excel, CSV, XML, JSON, PDF, Parquet etc</h4><h4>Database — SQL Server, MySQL, PostgreSQL, SAP, Amazon Redshift, Snowflake, Oracle, etc</h4><h4>Power Platform — Power BI datasets, dataflows, Dataverse, etc</h4><h4>Azure — Azure SQL Db, Blob storage, Cosmos DB, Data bricks, Data lake, etc</h4><h4>Online Services — Sharepoint, dynamics, Salesforce reports, Google analytics, Github, etc</h4><h4>Other — Web, Blank queries, Spark, Python script, R Hive, etc.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*dBPwuC3Dh2WWFFYTwogTMA.gif" /></figure><p>Power BI Desktop has 3 views namely, Report View, Model View and Data View.</p><p><strong>Report View</strong> — This is a blank canvas which is used to draw visuals and graphs to create reports.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jYyFnrjgAz4JRxGKVrpvFA.png" /><figcaption>Report View</figcaption></figure><p><strong>Data View</strong> — This view is used to view the underlying data from the source, it is a quick reference to data where we can read and validate data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Od3b7HW64-zeZ31aIauFaQ.png" /><figcaption>Data View</figcaption></figure><p><strong>Model View</strong> — This view visualizes all the source schema setup and its relationship if connected to each other. A relationship is where two or more tables are linked if they are related.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fv8JbHaKw-v0QDiAuMWC6A.png" /><figcaption>Model View</figcaption></figure><p><strong>Fields Pane</strong> contains Table name and its columns from which we drag and drop to create any visual.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P0U8VqZE4QZZJanrxnP4-g.png" /><figcaption>Fields Pane</figcaption></figure><p><strong>Visualization Pane</strong> contains default visuals that can be used in creating reports and options to customize axes, colors, drag additional columns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/211/1*Gi25L6pVye9b_6l5YfdaYA.png" /></figure><p><strong>Filters Pane</strong></p><ol><li>When you add a visual to a report canvas, Power BI automatically adds a filter to the Filters pane for each field in the visual.</li><li>To build your Filters pane, drag other fields of interest into the Filters pane either as visual, page, or report level filters.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*zUGwfFnAb39AHTp8GwTh5g.png" /><figcaption>Filters Pane</figcaption></figure><h3># Slicers</h3><p>To create a slicer we need to select a slicer visual from charts and drag and drop columns of our choice.</p><p>There are 2 variations in slicers — Horizontal, vertical slicers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*O-PMtLOMf-hGnAQU-rWnSg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*uHERKpYl4vtOw0rOprFcSA.png" /></figure><p>Vertical slicers can be a list or dropdown , Numerical / Date slicers can be additionally set up like a sliding range.</p><h3># Duplicate removal</h3><p>Duplicated entry in the table can be due to manual error or because of repeated operations to a table. It is necessary to remove these rows so as to avoid misinterpretation of data.</p><p>To remove duplicate values-</p><p><strong>Select columns where duplicates has to be removed&gt; click on Home tab&gt; Drop Down remove rows &gt; Click on Remove duplicate rows</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JkStTbNdcsiO9mu6e_4Omg.png" /></figure><h3># Remove nulls or errors</h3><p>When rows of an entire table are blank or Null it is called blank row.</p><p>To remove blank rows from table</p><p><strong>click on Home tab&gt; Drop Down remove rows &gt; Click on Remove blank rows</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TZ2quuBGefx7c4bN.png" /></figure><p>To remove Error from table</p><p><strong>Select columns where errors are present&gt; click on Home tab&gt; Drop Down remove rows &gt; Click on Remove Errors</strong></p><p>Note: If a column has errors then this will throw an exception while loading data at the initial stage to load without errors.</p><h3># Replacing Values</h3><p>To replace data values from any column</p><p><strong>Select desired column &gt; click on Transform tab&gt; Drop Down Replace values &gt; Click on Replace values</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*33Kz_iFDYJpRQo6X.png" /></figure><h3># KPI (Key Performance Indicator)</h3><p>KPI stands for <strong>Key Performance Indicator</strong>, it’s a visual that communicates the amount of progress made towards a measurable goal.</p><p><strong><em>Often in your company project, you must have heard the term KPI. KPIs provide targets for teams to shoot for, milestones to gauge progress, and insights that help people across the organization make better decisions. KPIs are a key visualization type used to convey high-level metrics to the end-users. In simple terms, it indicates whether they are on track or off-track wrt the target.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*7YC0jPo7VA6yHBfNKXEXvQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fca79faa93c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[R for Data Science]]></title>
            <link>https://medium.com/@tanmoywork23/r-for-data-science-43805f5a1ae3?source=rss-9e6f81c3b5d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/43805f5a1ae3</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-analytics-courses]]></category>
            <category><![CDATA[r-language]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[r]]></category>
            <dc:creator><![CDATA[Tanmoy Banerjee]]></dc:creator>
            <pubDate>Thu, 18 May 2023 13:59:15 GMT</pubDate>
            <atom:updated>2023-05-21T04:32:35.796Z</atom:updated>
            <content:encoded><![CDATA[<h3>by ( Tanmoy banerjee )</h3><p><strong>R — language</strong> is an open source <strong>scripting language</strong> for <strong>predictive analysis</strong> and <strong>data visualization</strong>.</p><p>The “<strong>R</strong>” name is derived from the first letter of the names of its two developers, <strong>Ross Ihaka</strong> and <strong>Robert Gentleman</strong>, who were associated with the University of Auckland at the time. It includes functions that support <strong>linear modeling</strong>, <strong>non-linear modeling</strong>, <strong>classical statistics</strong>, <strong>classifications</strong>, <strong>clustering</strong> and more.</p><p>The scripting work can be done for R-language in the <strong>R-Studio</strong> where for scripting we uses the numerical / mathematical operators like +, — , * ,/ and comparison operators like &gt; , &lt; and regression analysis etc. very easily and can achieve our desired results also through visualization.</p><p><strong>R vs Python</strong></p><p>The base structure and things we uses in R &amp; Python are very similar , so many times we have questions on our mind why both why not just one ? Now the answer is little interesting both are same on base structure but different on the use cases. As R is mostly use for Statistical Analysis ( Stat oriented cases it performs better ) &amp; Python mostly uses for machine learning , deep learning &amp; large scale web applications.</p><p><strong><em>It’s debatable when it comes to the usage of Python and R. Both of these languages come with their advantages and disadvantages. Python is used by a lot of people for multiple people, but R is also under usage. Python is used for a wide range of features, and R is used majorly for statistics. It depends upon the user to pick the language based on the requirement.</em></strong></p><p>Now in R — Language there is Operators → Assignment Operators, Comparison etc.</p><p><strong>Data Types</strong></p><p>It means assigning a value to a variable , it can be integer , float( double) ,complex. pre-defined etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PcKKhWGmPT-X2hYWdliwOw.png" /></figure><p>This are the Data-types integer, double, complex, character, string , logical etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4IIyd5hLhkupSYhoZSNE4A.png" /></figure><p>Now, Here is the interesting part from here you can understand a major difference between R &amp; Python.</p><p><strong>If you look closely you can see in the above image we mentioned in integer data type x &lt;- 2L , now what is the ‘“L” ? and in the 2nd image x = 2L is integer data type for ‘x’ but when y = 2 it is showing the double / float data type.</strong></p><p><strong><em>Reason behind it whenever in R-Language we mention ‘L’ for denoting as an integer, as in R any number pre-dominantly defined as double as R thinks that after calculation we may have the answer in decimals. If not R treat that as double . In R we called float / decimal numbers “double”, as you can see on above image. so for mentioning integer specific we have to put aa “L” after the number.</em></strong></p><p><strong>Variables</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*GEmV3m9IfmcgJ4rhLsg7iw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*1IQUwmL3gZT_Qs8ZDkgxIg.png" /></figure><p>Now How to calculate something by assigning a value to a variable and checking calculating operators</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tlx04x9ZWjTy2Hn8Hzz51A.png" /></figure><p>In Python concatenation is done by adding those and with a added space. But in R concatenation is done by a function named “<strong>paste</strong>”</p><p><strong><em>Ex —</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XMNR5kFEbI23irKnHDcQpg.png" /></figure><p><strong><em>Here, we don’t have to mention the spaces it automatically added the spaces between words.</em></strong></p><p><strong>Logical Operators</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-r73dKZSmCjZ_dQyoGGsGQ.png" /></figure><p>“<strong>isTrue()</strong>”— <em>is a function of R that defines if a variable is attached with some comparison operator then we can define the function is true or not.</em></p><p><strong>Functions</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VWfDOFYV6CuV1cw9IxdqLw.png" /></figure><h3>#rnorm( )</h3><p>rnorm ( ) is stands for <strong><em>random number normalization</em></strong></p><p>There is mainly 4 types of norm( ) function -</p><p><strong><em>dnorm(x, mean = 0, sd = 1, log = FALSE)<br>pnorm(q, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)<br>qnorm(p, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)<br>rnorm(n, mean = 0, sd = 1)</em></strong></p><p>where,</p><p><em>x , q = vector of quantities</em></p><p><em>p = vector of possibilities</em></p><p><em>n = number of observations . If length(n) &gt; 1 ,the length is taken to be the number required</em></p><p><em>mean = vector of means</em></p><p><em>sd = vector of standard deviation</em></p><p><strong>n:</strong> It is the number of observations(sample size).</p><p><strong>mean:</strong> It is the mean value of the sample data. Its default value is zero.</p><p><strong>sd:</strong> It is the standard deviation. Its default value is 1.</p><pre>data &lt;- rnorm(10)<br>data</pre><pre>[1] -0.359721535 1.516744916 -0.380787719 0.345410241 0.321703671 <br>[6]-0.436644645 -0.267328311 -1.640269174 -0.190012636 -0.004461941</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i_C-Bxg3kI3DEH6UB2IhWw.png" /></figure><h3><strong>#Sequence function</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*XXikNoXSbzCZ_8kM0xiBcQ.png" /></figure><p><strong>Sequence Function </strong>→<em>seq(from= “ ”, to=“ ”, by = “ ” )</em></p><p>sequence function it’s start as from — to (as where to start &amp; how far it goes) and by means how much gap it has.</p><p><strong><em>As in the above image we can see the example seq(10,20,3)</em></strong></p><p><em>It started</em><strong> [ from 10 to 20 ] &amp; [ the gap between 3 ] so as o/p shows [ it started from 10 _3_ , 13 _3_, 16, _3_, 19<em> </em>] </strong><em>and it can’t go above 20 as 3 gaps so at max range is 20 here and the line ends on 19.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*oIWIcE-5zNwgMPgQOZczLw.png" /></figure><p>Here, in the example the <strong>seq</strong> function started [ from 10 to 25 , it’s basically the range , as take it as a starting pt. &amp; end pt. &amp; gap by 5 ] so the o/p is as shown in the above image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*ewIFAcGjBHET_OunqN4yCQ.png" /><figcaption>Here you can see o/p showed error its because here we give range 2:10 , instead of that we have to right seq(2,10,3) it’s the correct format</figcaption></figure><p><strong>Sequencing with many break points</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*a8JjWmnstOt4_2ry2OEGUw.png" /></figure><p>same as sequence function but here [ <strong>length . out </strong>] function breaks that length [ from 10 to 20 ] into <strong>50 pieces</strong> , so we can see now the <strong>data in even deeper.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*7hDwgnov-zTih9ovadZd5Q.png" /></figure><p><strong>seq_len( ) function display the complete step by step length of each numeric character starting from 1.</strong></p><p>seq_len (number) function creates a sequence that starts at 1 and with steps of 1 finishes at the number value. A common use of this function is to create indexes that match the length of a vector in order to make plots.</p><p><strong>seq_along( ) </strong><em>is a function that creates a vector that contains a sequence of numbers from 1 to the length of the object. In this case the object is the vector c , which has a length of 6 elements. Therefore seq_along( ) , creates a vector containing 1, 2, 3, 4, 5, 6.</em></p><h3><strong>#replicate function ( </strong>replicate the values no of times that mentioned )</h3><p><strong><em>replicate function</em></strong> does what the name suggests as replicate the value no of times we want.</p><p><strong>function</strong> = <strong><em>rep( “x” , times = “y” )</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*H66l44rfVAlpM5kpI43org.png" /></figure><p>As we can see this above image —</p><p>( i ) rep ( 5:6 , times = 10 ) → replicate the values 5:6 ( means 5 , 6 ) and how many times it going to replicate / copy = 10 ( times = 10 )</p><p>( ii ) rep (15 , times = 5 ) → replicate the values 15 and replicate the values 5 times</p><p>( iii ) rep.int ( 10 , times = 20 ) → replicate the values 10 7 replicate the values 20 times</p><p><strong>AS ALL THE PROCESS ARE SAME FOR rep ( ) FUNCTION</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*JMFB7F4sXd66nYJAchElsQ.png" /></figure><p>Now, rep_len ( 15 , length.out = 10 ) as rep_len does the same job as previous replicate function did.</p><p>And in this above image you can also see the string replication.</p><h3><strong>#Range replication</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*yBTe3BhO7mdPuz3wYgHPrQ.png" /></figure><p>Here, is the <strong><em>Range replication</em></strong></p><p>replication format is the same as previous but just one difference<strong> in place</strong> <strong>of</strong> “<strong> times</strong> “ now comes “ <strong>each</strong> “ . As range 1:10 ( <strong><em>means 1 ,2,3,4,5,6,7,8,9,10 all replicate / appear 3 times</em></strong> ).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*zgivieOx5R3y99VSbwSTrw.png" /></figure><p>It is another rep ( ) format where nothing is mentioned AS pervious like times / each . In stead of just [ <strong>rep ( 15 , 12 )</strong> ] means [ <strong>replicate 15 just 12 times</strong> ]</p><h3><strong>#Combine Function</strong></h3><p>Combine function just combine variables values index wise.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*ISdnXDWh71WHOTcFTC7Bog.png" /></figure><p>As , you can see in this here index[1] of variable “v” combine with index[1] of variable “d” and similarly with index[2] and index[3] they all combine means added to each other indexes. so that’s how o/p generate as [27,43,54]</p><h3><strong>#Vectors in R</strong></h3><p><strong><em>Vector</em></strong> is a list of variables &amp; it consists of a collection of numbers, arithmetic expressions, logical values or character strings. The memory of the vector increase / decrease depends on the elements are adding or removing from it.</p><p>Vectors are the mostly basic R data objects and there are six types of vectors → <strong>logical, integer, double, complex, character and raw</strong>.</p><h4><strong>??? How to create a Vector ???????</strong></h4><p><strong><em>Vectors</em></strong> are generally created <strong><em>using the c() function</em></strong>. It must have elements of the <strong><em>same type (means inside a vector you can use only one type of data type )</em></strong>, this function will try and <strong><em>coerce elements to the same type</em></strong>, if they are different. <strong>Coercion is from lower to higher types from logical to integer to double to character</strong>.</p><h4>Types of Vector →</h4><p>i ) Single element Vector</p><p>ii ) Multiple element Vector</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*bO7qZh3IuOa7GKMnGWT0fQ.png" /></figure><p>Vector is like a connection of elements which can stored the data. Like in this above image we can see a <strong>“Vector”</strong> named as <strong>“first vector” [ in this vector all of the attributes / elements are double’s ( not integers ) , as we mentioned it earlier in “R” if denote some numeric as integer you must put a “L” after the integer like “30L” , as here we also see that function → is . numeric( first vector ) is showing “ False” and for is . double it is showing “ True” ]</strong></p><p>For assigning the vector you must have a few things in mind : 1 ) after assigning a vector you have to use c( ) / combine to store this or hold the values in the vector. 2) you can’t use many data types in R’s Vector.</p><h4>*** Difference between Vector &amp; Array ***</h4><p><strong><em>Vector</em></strong> → <strong>Dynamic</strong> in memory allocation</p><p><strong><em>Array</em></strong> → <strong>Static</strong> in memory allocation</p><p><em>### means one’ an array is created you can’t increase / decrease the size of the memory.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*CaybS0X0ROVMH06LKaPkPg.png" /></figure><p>### Here, we can observe that “A” is a vector which is attributes of “character” data-type. In indexing in “R” it starts from [1] not like “Python” which starts from [0]. But when we are trying fetch the indexing of “good” like we normally do on Python here it can’t be possible, it give you the whole index value of it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*Dqzu3qTv7ce0p6gdk0kcdA.png" /><figcaption>Another Example</figcaption></figure><h4># Vector Creation</h4><p>a vector can be created by simply assigning some values to a variable.</p><h4>SYNTAX :- var _ name = value ( single element vector ) [ a=10]</h4><h4>var_name2 = c( value ) ( multi element vector ) [ z = c(1,2,3) ]</h4><p>[ <strong><em>c is for hold multiple elements</em></strong> ]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*vYdOPSKvmkKGhGTmkkt6hQ.png" /></figure><p>The above image contains a vector in R-Studio which is “<strong>character vector</strong>” so here we can clearly see that for ( is.character ) function is True, ( is.null ) function is false and ( is.numeric ) too is false.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0GEuNwG-JcRFSdWqBL7BIA.png" /></figure><h4>O/P of the R — Script</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IXkh016i9mtO6PrGgt06bA.png" /></figure><h4># Indexing in R</h4><p><em>some </em><strong>input</strong><em> example related to indexing in R in</em> <strong>“R-Studio”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*dTjSoXd0HpW-TwQFXfGZeg.png" /></figure><p><strong>O/P </strong><em>results of this above i/p in</em> “<strong>R-Studio</strong>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dxsJHeDpK0nHqsLsm9CgwQ.png" /></figure><p>The explanation of the indexing in “R” is going to brief and in detail because people are often very much confuse about indexing in “R” &amp; “Python” . Both are very different from each other and we are going to see where it’s different from each other.</p><h4># explanation of the above R-Script images about indexing</h4><ol><li>In R indexing <strong>starts from 1 not from ‘0’</strong> .</li><li>In R if we write x [-1] that means except first value print other values , as in case of Python x [-1] display the last value . Similarly if we write x[-2] the in R it going to print other values which are in the vector x apart from 2nd value as we write -2 .</li><li>If we write x[-3:-5] then it means eliminate the value of the range of 3:5 (3,4,5) and print other elements hold by the vector x.</li><li>As we can write the same thing as x[-3:-5] / x[c(-3,-4,-5)] both are going to give similar o/p . It just achieving the result in different ways.</li><li>x[1] means calls the first value as indexing starts from 1 here in R &amp; so on…</li></ol><p><strong><em>Some function of R are</em></strong></p><p>is.numeric( ) = check it is numeric or not</p><p>is.double( ) = check it’s double or not ( decimal pts. )</p><p>isTrue( ) = check the logical operation True or not</p><p>isFalse( ) = check the logical operation False or not</p><p>typeof( ) = check the variable’s data type</p><p>rnorm( ) = generating random numbers</p><p>paste ( ) = to print or paste</p><p>sqrt ( ) = square root of any numeric digit</p><h3># Loop’s</h3><p>When we heard the term loop the first thing comes to our mind constantly bound in something for endless time , that’s “loop” .</p><p>In <strong>R</strong> we require a control structure <strong>to run a block of code for multiple times</strong>. <strong>Loop</strong> is a code statement that allows <strong>multiple executions of a</strong> <strong>statement </strong>or<strong> a set of statements</strong>. The word ‘looping’ means <strong>cycling </strong>or <strong>iterating</strong>.</p><h4># How Loop Works ???</h4><p>Loop needs a query in the loop structure. If the answer to that query requires an action, it will be executed. The same query is asked again and again until further action is taken. Any time the query is asked in the loop, it is known as an iteration of the loop. There are two components of a loop, the control statement, and the loop body. The control statement controls the execution of statements depending on the condition and the loop body consists of the set of statements to be executed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*caBlg83BzxvzHUSJF1SF2A.png" /><figcaption>for loop working structure</figcaption></figure><h3>There are three types of loops in R programming:</h3><ul><li>For Loop</li><li>While Loop</li><li>Repeat Loop</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43805f5a1ae3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL Strata Scratch Questions]]></title>
            <link>https://medium.com/@tanmoywork23/sql-strata-scratch-questions-e57426225522?source=rss-9e6f81c3b5d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/e57426225522</guid>
            <dc:creator><![CDATA[Tanmoy Banerjee]]></dc:creator>
            <pubDate>Fri, 07 Apr 2023 02:06:55 GMT</pubDate>
            <atom:updated>2023-04-07T02:06:55.924Z</atom:updated>
            <content:encoded><![CDATA[<p>Q1</p><h3>Order Details ( Amazon / Shopify )</h3><p>Find order details made by Jill and Eva. Consider the Jill and Eva as first names of customers. Output the order date, details and cost along with the first name. Order records based on the customer id in ascending order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*rO_h8gUTc70N1Lfc8FIDig.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZTNMReysUH7R-32EZ-u7EQ.png" /></figure><p>Q2</p><h3>Workers With The Highest Salaries (Amazon / DoorDash )</h3><p>You have been asked to find the job titles of the highest-paid employees.</p><p>Your output should include the highest-paid title or multiple titles with the same salary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*Resdg8RLeKiwhinzqusU_w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*cgCUpBn5eUf8GCGXJ_Vp3g.png" /></figure><p>Q3</p><h3>Find the top 10 ranked songs in 2010 (Spotify)</h3><p>What were the top 10 ranked songs in 2010? Output the rank, group name, and song name but do not show the same song twice. Sort the result based on the year_rank in ascending order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*dcWqcg5H2xTSxG1TD7Rmmg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*F7buo43Ve3v-ukIxV7k_3Q.png" /></figure><p>Q4</p><h3>Salaries Differences ( LinkedIn / Dropbox )</h3><p>Write a query that calculates the difference between the highest salaries found in the marketing and engineering departments. Output just the absolute difference in salaries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*8jPul63dky5ZKUh1W4jHDw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/107/1*9qKyeQvdmW7WLJb9ca_IZw.png" /></figure><p>Q5</p><h3>Customer Details ( Apple / Amazon )</h3><p>Find the details of each customer regardless of whether the customer made an order. Output the customer’s first name, last name, and the city along with the order details. You may have duplicate rows in your results due to a customer ordering several of the same items. Sort records based on the customer’s first name and the order details in ascending order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dXt7U30FSPL1UjHTk-u1Aw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h_LPE5cjkhNHZufhHQH4_w.png" /></figure><p>Q6</p><h3>Number Of Bathrooms And Bedrooms ( Airbnb )</h3><p>Find the average number of bathrooms and bedrooms for each city’s property types. Output the result along with the city name and the property type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*j0-x25qFcPGyaYzDpTyp8w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j72b80koYeVDFWHhZJLWPA.png" /></figure><p>Q7</p><h3>Employees’ Without Annual Review (Uber)</h3><p>Return all employees who have never had an annual review. Your output should include the employee’s first name, last name, hiring date, and termination date. List the most recently hired employees first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t1pNiiVRNTTkVwsdesvMXQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rQLUsXlg883RhlXovWtWdQ.png" /></figure><p>Q8</p><h3>Find all posts which were reacted to with a heart (Meta/ Facebook)</h3><p>Find all posts which were reacted to with a heart. For such posts output all columns from facebook_posts table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PXDvT4KG-LIR7cSAOMrJDw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W5cSxNt6Nc2nIOfKJ55epQ.png" /></figure><p>Q9</p><h3>Number Of Units Per Nationality (Airbnb)</h3><p>Find the number of apartments per nationality that are owned by people under 30 years old. Output the nationality along with the number of apartments. Sort records by the apartments count in descending order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*J3Nr12sTldnPMkKo5_BmmA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ypn9ffsqCdpGl4-B-9DBvg.png" /></figure><p>Q10</p><h3>Number of Hires During Specific Time Period (Deloitte)</h3><p>You have been asked to find the number of employees hired between the months of January and July in the year 2022 <strong>inclusive</strong>. Your output should contain the number of employees hired in this given time frame.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*koNp2h2yf4jzLCjKeuwouQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/104/1*1ukUqvIB5la7pwAJ2amcKg.png" /></figure><p>Q11</p><h3>Find the number of entries per star (Yelp)</h3><p>Find the number of entries per star. Output each number of stars along with the corresponding number of entries. Order records by stars in ascending order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*t5wWvloN1elrGB0BReIX8g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*j6P_2BSNcy2MR2LLLloLTw.png" /></figure><p>Q12</p><h3>Lyft Driver Wages (Lyft)</h3><p>Find all Lyft drivers who earn either equal to or less than 30k USD or equal to or more than 70k USD. Output all details related to retrieved records.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qqMWnmUEBJ3cHZgKh5Gd4g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*x_CBfr5RCZZXYFsMD4HBEQ.png" /></figure><p>Q13</p><h3>Inactive Free Users(Ring Central)</h3><p>Return a list of users with status free who didn’t make any calls in Apr 2020.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ck56WOwE8mjn5mzo2WJc2w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kvGaWi9eMpVPBrKyHSmSAw.png" /></figure><p>Q14</p><h3>Total Shipment Weight (Amazon)</h3><p>Calculate the total weight for each shipment and add it as a new column. Your output needs to have all the existing rows and columns in addition to the new column that shows the total weight for each shipment. One shipment can have multiple rows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SHbBUtenKnSkERlIwCvP3Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hlnp_ybUoDm-wv2OEzm4jg.png" /></figure><p>Q15</p><h3>Change of Currency Exchange Rates (Goldman Sachs)</h3><p>You are given a list of exchange rates from various currencies to US Dollars (USD) in different months. Show how the exchange rate of all the currencies changed in the first half of 2020. Output the currency code and the difference between values of the exchange rate between July 1, 2020 and January 1, 2020.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4-jigkPPuUAd9-RbqoT6QA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*MhwhUJH4bW4XCR7uMTgh7A.png" /></figure><p>Q16</p><h3>Highest Salary &amp; Full Name (Amazon / Visa )</h3><p>Your output should include the full name of the employee(s) with the highest salary in one column and the corresponding salary in the other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xBJZPUv1JuGzDzyIPvHd7w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IlpUhrDHThEHff1OeyPZfQ.png" /></figure><p>Q17</p><h3>Gender With Generous Reviews (Airbnb)</h3><p>Write a query to find which gender gives a higher average review score when writing reviews as guests. Use the from_type column to identify guest reviews. Output the gender and their average review score.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e57426225522" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Strata Scratch Question]]></title>
            <link>https://medium.com/@tanmoywork23/python-strata-scratch-question-45c8ff93c822?source=rss-9e6f81c3b5d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/45c8ff93c822</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pandas]]></category>
            <category><![CDATA[pandas-dataframe]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[stratascratch]]></category>
            <dc:creator><![CDATA[Tanmoy Banerjee]]></dc:creator>
            <pubDate>Sun, 26 Mar 2023 15:16:50 GMT</pubDate>
            <atom:updated>2023-04-07T02:07:09.127Z</atom:updated>
            <content:encoded><![CDATA[<p>Q1</p><h3>Find the most profitable company in the financial sector of the entire world along with its continent(Forbes)</h3><p>→ Find the most profitable company from the financial sector. Output the result along with the continent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KJZ5IoM7J1ORGnnvwggrsA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*il485klCnm4IdNzr_d_BUA.png" /></figure><p>Q2</p><h3>Salaries Differences(Linkedin)</h3><p>Write a query that calculates the difference between the highest salaries found in the marketing and engineering departments. Output just the absolute difference in salaries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ftKBGigzTnUoc5uBS-IO9Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/93/1*UTSdRXGqTD25RvXTU0FIDA.png" /></figure><p>Q3</p><h3>Gender With Generous Reviews (Airbnb)</h3><p>Write a query to find which gender gives a higher average review score when writing reviews as guests. Use the from_type column to identify guest reviews. Output the gender and their average review score.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dF16tCycpRVzseNYC4Pevw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*N3IPt0CDmUVyFHtjd4W-aA.png" /></figure><p>Q4</p><h3>Order Details (Amazon ,Shopify)</h3><p>Find order details made by Jill and Eva. Consider the Jill and Eva as first names of customers. Output the order date, details and cost along with the first name. Order records based on the customer id in ascending order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SZVtqukjDbAg8QUXEMzqDQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QU8oq_k47t4G05T4FY-rMA.png" /></figure><p>Q5</p><h3>Bikes Last Used (Lyft , DoorDash)</h3><p>Find the last time each bike was in use. Output both the bike number and the date-timestamp of the bike’s last use (i.e., the date-time the bike was returned). Order the results by bikes that were most recently used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vQ7Bmi1v4f6jp2GVsRgLPA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*kiCanhjOCsB9rr8UviNGAg.png" /></figure><p>Q6</p><h3>Number of Speakers By Language (Google,Apple)</h3><p>Find the number of speakers of each language by country. Output the country, language, and the corresponding number of speakers. Output the result based on the country in ascending order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jV75EbRaSzJR9HNJpxzIFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*H6LrLwSLyFv6r3cjmCgx3w.png" /></figure><p>Q7</p><h3>Find the top 3 jobs with the highest overtime pay rate</h3><p>Get the job titles of the 3 employees who received the most overtime pay Output the job title of selected records.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m5je4gvycyNKsV5riRiHrw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*izsUN8OCLM3ReiybFb0wcQ.png" /></figure><p>Q8</p><h3>Find the total number of searches for houses Westlake neighborhood with a TV (Airbnb)</h3><p>Find the total number of searches for houses in Westlake neighborhood with a TV among the amenities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KBMQpBglSX_2_-THWE9HMg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/161/1*2NMxkv1GHKn78O6zqR1N3Q.png" /></figure><p>Q9</p><h3>Count the number of user events performed by MacBook Pro users (Apple)</h3><p>Count the number of user events performed by MacBookPro users. Output the result along with the event name. Sort the result based on the event count in the descending order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dqJ20CA36vnaPCoIwSLeyw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*ZlHjCpvOV_R7DkRpDVUxvw.png" /></figure><p>Q10</p><h3>Churro Activity Date</h3><p>Find the activity date and the pe_description of facilities with the name ‘STREET CHURROS’ and with a score of less than 95 points.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dqJ20CA36vnaPCoIwSLeyw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*3VmxQlN6aAjb2SfWGYQumw.png" /></figure><p>Q11</p><h3>Churn Rate Of Lyft Drivers (Lyft)</h3><p>Find the global churn rate of Lyft drivers across all years. Output the rate as a ratio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A2UNer9uRbcb2h5OnmhSKQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/114/1*1gJd_wC-YyFXiqjCP9Iwmw.png" /></figure><p>Q12</p><h3>Find the most dangerous places in SF</h3><p>Find the most dangerous places in SF based on the crime count per address and district combination. Output the number of incidents alongside the corresponding address and the district. Order records based on the number of occurrences in descending order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a0GTGPFLNfN4U1qC_gsKUA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e6J6o-FMgjS3HHyfskLQYA.png" /></figure><p>Q13</p><h3>Top Ranked Songs (Spotify)</h3><p>Find songs that have ranked in the top position. Output the track name and the number of times it ranked at the top. Sort your records by the number of times the song was in the top position in descending order.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45c8ff93c822" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL]]></title>
            <link>https://medium.com/@tanmoywork23/sql-2fdd160b711d?source=rss-9e6f81c3b5d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/2fdd160b711d</guid>
            <category><![CDATA[data-analytics-courses]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[introduction-to-sql]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-analytics]]></category>
            <dc:creator><![CDATA[Tanmoy Banerjee]]></dc:creator>
            <pubDate>Sun, 12 Mar 2023 07:50:37 GMT</pubDate>
            <atom:updated>2023-03-12T13:27:09.623Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>Introduction to SQL</em></strong></p><p><strong>SQL</strong> — <em>Structured Query Language ( Structured = it has a spreadsheet like structure with Row’s and Column’s ) (Query is the programming part of the language )</em></p><p>SQL is a programming language designed for managing and manipulating relational databases. In the field of Data analysis and Data Science its use case is huge.</p><p>A normal SQL query looks like</p><pre>select * from database</pre><p>but when all major parts of SQL functions are applied on a query, <em>then it look like this</em></p><pre>SELECT DISTINCT column, AGG_FUNC(column_or_expression), …<br>FROM databsae1 a<br>    JOIN database2 b<br>      ON database1.column = database2.column<br>    WHERE constraint_expression<br>    GROUP BY column<br>    HAVING constraint_expression<br>    ORDER BY column ASC/DESC<br>    LIMIT count OFFSET COUNT<br></pre><p><strong>Query order of Execution</strong></p><ol><li><strong>From and join’s</strong></li></ol><p><em>The </em><strong><em>Form</em></strong><em> clause and </em><strong><em>Join’s </em></strong><em>are going to executed first to determine the total data in the dataset that is being queried. Subqueries are also included in this part for execution. And while processing this and joining two or more tables by using joins it creates a new table where previous tables are merged according to the joins.</em></p><p><strong>Joins</strong></p><p>There are many kind of joins for merging two / more than two tables</p><ol><li>Inner Join</li><li>Left Join</li><li>Right Join</li><li>Self Join</li><li>Outer Join</li></ol><p>Before going deep into the joins we have to clear about two important concepts of SQL [ 1. Primary key 2. Foreign Key ]</p><p><strong><em>Primary Key-</em></strong></p><ol><li>The Primary key constraints uniquely identifies each record in a table / database.</li><li>Primary key must contains unique values in it( means every value in this column can not be repeated it has to be unique ).</li><li>It can not contains null values.</li><li>In a table / database there can be only 1 Primary Key .</li><li>Primary key can consist of single or multiple columns (fields).</li></ol><h3>SQL PRIMARY KEY on a TABLE</h3><pre>#MS-SQL<br>CREATE TABLE new (<br>    ID int NOT NULL,<br>    LastName varchar(80) NOT NULL,<br>    FirstName varchar(80),<br>    Age int,<br>    PRIMARY KEY (ID)<br>);<br># you have to mention the primary key column while creating the database<br><br># SQL Server / Oracle / MS Access<br><br>CREATE TABLE NEW (<br>    ID int NOT NULL PRIMARY KEY,<br>    LastName varchar(80) NOT NULL,<br>    FirstName varchar(80),<br>    Age int<br>);</pre><h3>SQL PRIMARY KEY on ALTER TABLE</h3><p><em>To create a </em>PRIMARY KEY <em>constraint on the &quot;ID&quot; column when the table is already created, use the following SQL</em></p><pre>ALTER TABLE new<br>ADD PRIMARY KEY (ID);</pre><h3>DROP a PRIMARY KEY Constraint</h3><p><em>To drop a</em> PRIMARY KEY<em> constraint, use the following SQL</em></p><pre>ALTER TABLE new<br>DROP PRIMARY KEY;</pre><p><strong><em>Foreign Key-</em></strong></p><p><em>A</em> FOREIGN KEY<em> is a field or collection of fields in one table, that refers to</em> <em>the</em> <em>Primary Key</em> <em>in another table.</em></p><p><em>The table with the foreign key is called the child table, and the table with the primary key is called the referenced or parent table.</em></p><p><em>A </em><strong><em>foreign key</em></strong><em> is a column or combination of columns that is used to establish and enforce a link between the data in two tables to control the data that can be stored in the foreign key table.</em></p><p><em>A </em><strong><em>foreign key</em></strong><em> containing null values cannot match the values of a parent key, since a parent key by definition can have no null values. However, a null foreign key value is always valid, regardless of the value of any of its non-null parts and it can be duplicated.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*eYiXPgUpAkX7PCR01S2g1A.png" /><figcaption><strong>Primary key Table(PERSONS)</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*vMOpnzR74JXT9XGSvTTWcg.png" /><figcaption><strong>Foreign Key Table (ORDER)</strong></figcaption></figure><p><em>The “PersonID” column in the “Persons” table is the </em><em>PRIMARY KEY in the &quot;Persons&quot; table.</em></p><p><em>The “PersonID” column in the “Orders” table is a </em><em>FOREIGN KEY in the &quot;Orders&quot; table.</em></p><h3>SQL FOREIGN KEY on CREATE TABLE</h3><pre>CREATE TABLE Orders (<br>    OrderID int NOT NULL,<br>    OrderNumber int NOT NULL,<br>    PersonID int,<br>    PRIMARY KEY (OrderID),<br>    FOREIGN KEY (PersonID) REFERENCES Persons(PersonID)<br>);</pre><h3>SQL FOREIGN KEY on ALTER TABLE</h3><p><em>To create a </em><em>FOREIGN KEY constraint on the &quot;PersonID&quot; column when the &quot;Orders&quot; table is already created</em></p><pre>ALTER TABLE Orders<br>ADD FOREIGN KEY (PersonID) REFERENCES Persons(PersonID);</pre><h3>DROP a FOREIGN KEY Constraint</h3><pre>ALTER TABLE Orders<br>DROP FOREIGN KEY FK_PersonOrder;</pre><p><strong>Inner Join</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/291/1*28b_bAsEPYvBmuITmucpuQ.png" /><figcaption><strong>Inner Join Back End Process</strong></figcaption></figure><p><em>There are 2 tables A is the primary key of one table and B is foreign key of another table. if they are going to be joined by Inner Join, then the common elements between those 2 columns A &amp; B are going to appear as a result just like the above image.</em></p><pre>select * from table_1 a<br>inner join<br>table_2 b<br>on a.column = b.column</pre><p><strong>Left Join</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/292/1*ZVAEpOOV6bjkRyqCyIk8BA.png" /><figcaption><strong>Left Join Back End Process</strong></figcaption></figure><p><strong><em>Left Join = Inner Join + ( rest of the elements on left side table )</em></strong><em>. so , to perform left join at first the two tables gonna perform a inner join and take all those common elements between them after that rest of the elements from left table are going to appear in the result.</em></p><pre>select * from table_1 a<br>left join<br>table_2 b<br>on a.column = b.column</pre><p><strong>Right Join</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/292/1*FXQo4-vW1yEVoM0yYWt-Bw.png" /><figcaption><strong>Right Join Backend Process</strong></figcaption></figure><p><strong><em>Right Join = Inner Join + ( rest of the elements on right side table )</em></strong><em>. so , to perform left join at first the two tables gonna perform a inner join and take all those common elements between them after that rest of the elements from right table are going to appear in the result.</em></p><pre>select * from table_1 a<br>right join<br>table_2 b<br>on a.column = b.column</pre><p><strong><em>Scenario_1</em></strong></p><p><em>Manager asks you to make a list of employees with their respective depts.</em></p><pre>select<br>e.employee_name, d.dept_name<br>from<br>employee e<br>inner join / join<br>department d <br>on e.employee_id = d.employee_id</pre><p><strong><em>Scenario_2</em></strong></p><p><em>Fetch all employee name and the departments they belongs to.</em></p><pre>select<br>e.employee_name, d.dept_name<br>from<br>employee e<br>left join<br>department d <br>on e.employee_id = d.employee_id</pre><p>( <strong>Why left join is used here rather than inner join</strong> &gt; <em>on the left table which is employee table has the all the employee name and right table department table has the necessary departments the employees are in.)</em></p><p><strong><em>Query is fetch all employees with their departments, so all employee name should be their along with which employees whom has the departments with their own.</em></strong></p><p><strong><em>Scenario_3</em></strong></p><p><strong>Fetch all departments with employees in it</strong></p><pre>select<br>e.employee_name, d.dept_name<br>from<br>employee e<br>right join<br>deparment d<br>on <br>e.employee_id = d.employee_id</pre><p><em>on the right table department table has the all department name and left table employee table has the necessary employees whom the departments they are in. Query is fetch all departments with their respective employee, so all department name should be their along with which employees are there.</em></p><p><strong>Cross Join</strong></p><p>Just think you are having a date with your partner and both of you just landed on a <strong><em>restaurant , </em></strong>now you ordered the menu card and it has 2 sections in it-</p><p>i) Meals ii) Drinks &amp; Beverages</p><p>Now you can’t decide which to order with that which drinks you should take because you have many options in your hand.</p><p>So, from that infinite possibilities the Cross Join appeared. EX:- Table1 = Meals and Table2 = Drinks &amp; Beverages</p><pre>select <br>t1.table1 , t2.table2<br>from table1<br>cross join <br>table2</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*zH6mygCUvs29Ew0QPrzzGQ.png" /><figcaption><strong>Cross Join</strong></figcaption></figure><p><strong>Full Join</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*MXkNZYF6ZBT5qCeOHEJlNA.png" /><figcaption><strong>Full Join Back End Process</strong></figcaption></figure><p><em>“ Imagine your manager comes to you and says “Give me one employee record file where everything is there about employees” , but you know employee table and department table doesn’t have all records parallel to each other …. so for this type of task full join / full outer join is there”</em></p><p><strong><em>Full Join = ( inner join + rest of the records of left side table + rest of the records from the right side table )</em></strong></p><pre>select<br>e.employee_name, d.dept_name<br>from<br>employee e<br>full join<br>deparment d<br>on <br>e.employee_id = d.employee_id</pre><p><strong>Combination Joins</strong></p><p><em>“Suppose your manager again comes to you and ask you to “ fetch the details of employees with their corresponding departments “ and now he wants you to add their location with country that to on a new column “.</em></p><p><em>Previously you have employee table and department table , but now you also have location table ( which has 1 row 1 column ) / ( multi row’ s and multi columns ) but value is all the same cause all of the employees location is same.</em></p><p>For that,</p><pre>select<br>e.employee_name, d.dept_name, country l<br>from<br>employee e<br>inner join<br>deparment d<br>on <br>e.employee_id = d.employee_id<br>cross join<br>location l<br><br>### but if region is different then we can&#39;t use cross join then we have to <br>use  left/right join according to the data.<br></pre><p><strong>Self Join</strong></p><p><em>Self Join is kind of a join when a table join with itself , it’s a conditional join.</em></p><p>Suppose you have a data that contains <em>emp_id , emp_name, sr_id, salary</em></p><p>Now your manager asks you to give him the data of “<em> can show which employee is under which sr. employee”</em></p><pre>select <br>emp_name .jr as jr.emp,<br>emp_name as sr.emp<br>from employee jr<br>self join<br>employee sr<br>on jr.emp_id = sr.sr_id</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2fdd160b711d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>