{"id":8430,"date":"2018-05-04T09:40:41","date_gmt":"2018-05-04T09:40:41","guid":{"rendered":"https:\/\/assignment.essayshark.com\/blog\/?p=8430"},"modified":"2022-01-05T10:53:45","modified_gmt":"2022-01-05T10:53:45","slug":"creating-sql-queries-for-data-analysis","status":"publish","type":"post","link":"https:\/\/assignmentshark.com\/blog\/creating-sql-queries-for-data-analysis\/","title":{"rendered":"Creating SQL Queries for Data Analysis"},"content":{"rendered":"<h2 style=\"text-align: center;\"><b>Analytic SQL Queries<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">In this guide, we will develop our skill of creating analytic SQL queries based on the requirements of the database users.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">We have a database of CD disks, and in the table view it will look like the following:<\/span><\/p>\n<p><!--more--><\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400;\">CDtype<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Type code<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Type name<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Price<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Software<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Software code<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Software name<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Software version<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Application<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Application date<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Client code<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Software code<\/span><\/p>\n<p><span style=\"font-weight: 400;\">CD type code<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Client<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Client code<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Surname<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Name<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Address<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Company<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">We need to compose analytic queries to answer such questions:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">What program is the most popular?<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">How much has a specific client paid on a specific day?<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Which customers haven\u2019t ordered a specific program?<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">What are the addresses of the clients who ordered a specific CD type on a certain date?<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">What CD type has been ordered by the clients who ordered a certain program?<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">The ER diagram of our database looks like this:<\/span><\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8444 size-full\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_1.png\" alt=\"\" width=\"1254\" height=\"797\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_1.png 1254w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_1-300x191.png 300w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_1-768x488.png 768w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_1-1024x651.png 1024w\" sizes=\"auto, (max-width: 1254px) 100vw, 1254px\" \/><\/a><\/p>\n<p>[code]<\/p>\n<p>CREATE DATABASE CD<\/p>\n<p>CREATE TABLE CDtype (ID int NOT NULL,<br \/>\nTName nvarchar(40) NOT NULL,<br \/>\nPrice decimal(12, 2) NOT NULL,<br \/>\nPRIMARY KEY(ID))<\/p>\n<p>CREATE TABLE Applications (ID int NOT NULL,<br \/>\nAName nvarchar(40) NOT NULL,<br \/>\nAVersion decimal(12, 0) NOT NULL,<br \/>\nPRIMARY KEY (ID))<\/p>\n<p>CREATE TABLE Clients (ID int NOT NULL,<br \/>\nFullName nvarchar(40) NOT NULL,<br \/>\nAddress nvarchar(40) NOT NULL,<br \/>\nCompany nvarchar(40) NOT NULL,<br \/>\nPRIMARY KEY (ID))<\/p>\n<p>CREATE TABLE Plea (ClientsID int NOT NULL,<br \/>\nApplicationsID int NOT NULL,<br \/>\nCDtypeID int NOT NULL,<br \/>\nDate date NOT NULL,<br \/>\nFOREIGN KEY (ClientsID) REFERENCES Clients(ID),<br \/>\nFOREIGN KEY (ApplicationsID) REFERENCES Applications(ID),<br \/>\nFOREIGN KEY (CDtypeID) REFERENCES CDtype(ID))<\/p>\n<p>INSERT INTO CDtype (ID , TName , Price)<br \/>\nVALUES (1 , &#8216;CD-ROM&#8217;, 150.00),<br \/>\n(2 , &#8216;CD-R&#8217;, 200.00),<br \/>\n(3 , &#8216;CD-RW&#8217;, 300.00);<\/p>\n<p>INSERT INTO Applications(ID , AName , AVersion)<br \/>\nVALUES (1 , &#8216;Visual Studio&#8217;, 2013),<br \/>\n(2 , &#8216;PyCharm&#8217;, 2014),<br \/>\n(3 , &#8216;Unity&#8217;, 2015);<\/p>\n<p>INSERT INTO Clients (ID , FullName, Address, Company)<br \/>\nVALUES (1 ,&#8217;Kolishchak Bohdan Vladimirovich&#8217;, &#8216;st. Yangelya 22&#8217;, &#8216;Looksery&#8217;),<br \/>\n(2 ,&#8217;Jura Roman Serhvyovych&#8217;, &#8216;st. Shevchenka 11&#8217;, &#8216;ITEnterprise&#8217;),<br \/>\n(3 ,&#8217;Hrebeniuk Bogdan Ruslanovych&#8217;, &#8216;st. Borschagivska 1&#8217;, &#8216;Epam&#8217;);<\/p>\n<p>INSERT INTO Plea (ClientsID , ApplicationsID , CDtypeID, Date)<br \/>\nVALUES (1 , 1, 1, CONVERT(date, &#8217;19\/09\/15&#8242;, 3)),<br \/>\n(2 , 2, 1, CONVERT(date, &#8217;19\/09\/15&#8242;, 3)),<br \/>\n(3 , 1, 3, CONVERT(date, &#8217;11\/10\/15&#8242;, 3));<\/p>\n<p>&#8211;1<br \/>\nSelect top 1 with ties Max(AName) AS Favourite From Plea  join Applications on Plea.ApplicationsID=Applications.ID<br \/>\nGroup by Applications.ID<br \/>\nOrder by Favourite DESC<\/p>\n<p>[\/code]<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8442\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_2-300x98.png\" alt=\"\" width=\"233\" height=\"76\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_2-300x98.png 300w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_2-768x252.png 768w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_2-1024x336.png 1024w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_2.png 1600w\" sizes=\"auto, (max-width: 233px) 100vw, 233px\" \/><\/a><\/p>\n<p>[code]<br \/>\n&#8211;2<br \/>\nSelect CAST(Sum(CDtype.Price) AS INT) FROM Plea join CDtype on Plea.CDtypeID=CDtype.ID<br \/>\nWhere Date = &#8216;2015-09-19&#8217;<br \/>\nGroup by CDtype.Price<br \/>\nHaving Sum(CDtype.Price)&amp;amp;amp;gt;200<br \/>\n[\/code]<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8440 size-medium\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_3-300x131.png\" alt=\"\" width=\"300\" height=\"131\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_3-300x131.png 300w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_3-768x335.png 768w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_3-1024x446.png 1024w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_3.png 1515w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>[code]<br \/>\n&#8211;3<br \/>\nSelect FullName From Clients join Plea on Clients.ID=Plea.ClientsID<br \/>\nWhere Plea.ApplicationsID not in (Select Applications.ID From Applications Where AName=&#8217;PyCharm&#8217;)<br \/>\nOrder by FullName<br \/>\n[\/code]<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-8438\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_4-300x99.png\" alt=\"\" width=\"300\" height=\"99\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_4-300x99.png 300w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_4-768x254.png 768w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_4-1024x339.png 1024w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_4.png 1600w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>[code]<br \/>\n&#8211;4<br \/>\nSelect Address FROM Clients join Plea on Clients.ID=Plea.ClientsID join CDType  on Plea.CDtypeID=CDtype.ID<br \/>\nWhere Date=&#8217;2015-09-19&#8242; and TName=&#8217;CD-ROM&#8217;<br \/>\n[\/code]<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8436\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_5-300x153.png\" alt=\"\" width=\"241\" height=\"123\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_5-300x153.png 300w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_5-768x392.png 768w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_5-1024x523.png 1024w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_5.png 1399w\" sizes=\"auto, (max-width: 241px) 100vw, 241px\" \/><\/a><\/p>\n<p>[code]<br \/>\n&#8211;5<br \/>\nSelect TName FROM CDType JOIN Plea on CDtype.ID=Plea.CDtypeID join Applications on Applications.ID=Plea.ApplicationsID<br \/>\nWHERE Applications.AName=&#8217;Visual Studio&#8217;<br \/>\n[\/code]<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8434\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_6-300x158.png\" alt=\"\" width=\"216\" height=\"114\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_6-300x158.png 300w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_6-768x404.png 768w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_6-1024x539.png 1024w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_6.png 1378w\" sizes=\"auto, (max-width: 216px) 100vw, 216px\" \/><\/a><\/p>\n<p>[code]<br \/>\n&#8212;<br \/>\nSELECT ID, FullName FROM Clients<br \/>\nWHERE FullName LIKE &#8216;%ko%&#8217;<br \/>\n[\/code]<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8432\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_7-300x158.png\" alt=\"\" width=\"217\" height=\"114\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_7-300x158.png 300w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_7-768x404.png 768w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_7-1024x539.png 1024w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/sql_db_7.png 1378w\" sizes=\"auto, (max-width: 217px) 100vw, 217px\" \/><\/a><\/p>\n<p>[code]<br \/>\nUPDATE CDtype SET Price = 1000 WHERE Price IS NULL<br \/>\n[\/code]<\/p>\n<p>&nbsp;<\/p>\n<blockquote><p><i><span style=\"font-weight: 400;\">When dealing with your assignment, it is very easy to make mistakes with <\/span><\/i><i>SQL queries for data analysis<\/i><i><span style=\"font-weight: 400;\">. With our guide, it is possible to deal with the assignment without making any mistakes. Also, you can find more examples of tasks on AssignmentShark.com. You will have a greater chance of getting high grades after using our help. What difficulties do you have while dealing with your homework? You must remember that each problem can be solved if you get help from experts like ours.<\/span><\/i><\/p>\n<p><i><span style=\"font-weight: 400;\">Also, remember that there is an expert who has knowledge in your sphere of study and can solve your particular problem. Our experts can deal with any type of assignment. What will change when using our service? You will save your time and effort, and you can spend your time as you want while our expert works with your order. Unlike other services, we guarantee that your personal information will be secure and never passed to third parties. Solve all of your problems with our <a href=\"https:\/\/assignmentshark.com\/\" target=\"_blank\" rel=\"noopener\">assignment help<\/a>!<\/span><\/i><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Analytic SQL Queries In this guide, we will develop our skill of creating analytic SQL queries based on the requirements of the database users. We have a database of CD disks, and in the table view it will look like the following:<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53,35],"tags":[],"class_list":["post-8430","post","type-post","status-publish","format-standard","hentry","category-it","category-samples"],"_links":{"self":[{"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/posts\/8430","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/comments?post=8430"}],"version-history":[{"count":10,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/posts\/8430\/revisions"}],"predecessor-version":[{"id":12859,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/posts\/8430\/revisions\/12859"}],"wp:attachment":[{"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/media?parent=8430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/categories?post=8430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/tags?post=8430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}