{"id":218,"date":"2012-12-01T09:12:21","date_gmt":"2012-12-01T14:12:21","guid":{"rendered":"http:\/\/www.nytechnologist.com\/beyondthebasics\/?p=218"},"modified":"2015-06-13T23:11:11","modified_gmt":"2015-06-14T03:11:11","slug":"advanced-access-12-1-2012-day-2-of-2-vacation-list-database","status":"publish","type":"post","link":"https:\/\/www.nytechnologist.com\/beyondthebasics\/advanced-access-12-1-2012-day-2-of-2-vacation-list-database\/","title":{"rendered":"Advanced Access 12-1-2012 (Day 2 of 2 &#8220;Vacation List database&#8221;)"},"content":{"rendered":"<p><strong>Objective:\u00a0 Show all columns and rows from a table.<\/strong><\/p>\n<p>SQL Example 1: Start with the basic example below.<\/p>\n<blockquote><p>Select *<br \/>\nFrom T01_VacationList<\/p><\/blockquote>\n<p><strong>Objective:\u00a0 Filter rows and show all columns.<\/strong><\/p>\n<p>SQL Example 2: Filter and show all columns.\u00a0 Also use &#8220;V&#8221; to write SQL code more compactly.<\/p>\n<blockquote><p>Select *<br \/>\nFrom T01_VacationList as V<br \/>\nWhere V.Category = &#8216;Equipment&#8217;<\/p><\/blockquote>\n<p><strong>Note: \u00a0<\/strong><br \/>\n<em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Access 2010 uses single quote &#8216;\u00a0 &#8216; in SQL code.<\/em><br \/>\n<em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Access 2007 uses double quote &#8221;\u00a0 &#8221; in SQL code.<\/em><\/p>\n<p>The filter condition is defined by &#8220;Where&#8221;<br \/>\nWhere V.Category = &#8216;Equipment&#8217;<\/p>\n<ul>\n<li>Select &#8216;*&#8217; means that all the attributes will be displayed.<\/li>\n<li>&#8220;From&#8221; indicates the table which table is used.<\/li>\n<li>&#8220;As&#8221; indicates the table is given the shorthand name b<\/li>\n<li>To execute the query, click the RUN symbol &#8220;!&#8221; from SQL view.<\/li>\n<\/ul>\n<p><strong>Objective:\u00a0 Filter rows and show selected columns.<\/strong><\/p>\n<p>SQL Example 3: Filter and show selected columns.<\/p>\n<blockquote><p>Select Description, [Associated Price]<br \/>\nFrom T01_VacationList as V<br \/>\nWhere V.Category = &#8216;Equipment&#8217;<\/p><\/blockquote>\n<p><strong>Objective:\u00a0 Invert your filter using the &#8220;Not&#8221; operator.<\/strong><\/p>\n<p>SQL Example 4: Using &#8220;Not&#8221; operator.<\/p>\n<blockquote><p>Select *<br \/>\nFrom T01_VacationList as V<br \/>\nWhere Not( V.Category = &#8216;Equipment&#8217;)<\/p><\/blockquote>\n<p><strong>Objective: Use mathematical formulas to add a math driven column.<\/strong><\/p>\n<p>SQL Example 5: Find the Subtotal.<\/p>\n<blockquote><p>Select V.*, [Associated Price] * quantity as Subtotal<br \/>\nFrom T01_VacationList as V<\/p><\/blockquote>\n<p><strong>Objective:\u00a0 Use mathematical formulas to add a math driven column AND the sum.<\/strong><\/p>\n<p>SQL Example 6: Find the Subtotal.<\/p>\n<blockquote><p>Select sum([Associated Price] * quantity) as Subtotal<br \/>\nFrom T01_VacationList as V<\/p><\/blockquote>\n<p style=\"text-align: left;\"><span style=\"color: #0000ff;\"><em>Try using OR, AND, and &#8221; Like &#8216;a*&#8217; &#8221; with the &#8220;Where&#8221; parameter.<\/em><\/span><\/p>\n<p>\u00a0<strong>Objective:\u00a0 Using the UNION query to consolidate similar tables or queries.<\/strong><\/p>\n<p><em>First you will need to create and save two queries named q1 and q1.<\/em><\/p>\n<p>SQL Union Example: Create a union of q1 and q2.<\/p>\n<blockquote><p>Select [ID], [Description], [Category], [Associated Price]<br \/>\nFrom q1<\/p>\n<p>Union Select [ID], [Description], [Category], [Associated Price]<br \/>\nFrom q2;<\/p><\/blockquote>\n<p><em>Decipher the following query:<\/em><\/p>\n<p>SELECT [First Name1] AS [First Name],[Start Time1] AS [Start Time],[End Time1] AS [End Time],[Start Date], ([End Time]-[Start Time])*24 AS [Hours Available]<br \/>\nFROM [Form Number 01]<\/p>\n<p>UNION SELECT [First Name1] AS [First Name],[Start Time1] AS [Start Time],[End Time1] AS [End Time],[Start Date], ([End Time]-[Start Time])*24 AS [Hours Available]<br \/>\nFROM [Form Number 02]<\/p>\n<p>UNION SELECT [First Name1] AS [First Name],[Start Time1] AS [Start Time],[End Time1] AS [End Time],[Start Date], ([End Time]-[Start Time])*24 AS [Hours Available]<br \/>\nFROM [Form Number 03]<\/p>\n<p>UNION SELECT [First Name1] AS [First Name] ,[Start Time1] AS [Start Time],[End Time1] AS [End Time],[Start Date], ([End Time]-[Start Time])*24 AS [Hours Available]<br \/>\nFROM [Form Number 04];<\/p>\n<p><span style=\"text-decoration: underline;\">Below are the files for the Day 2 learning activities:<\/span><\/p>\n<p><a href=\"http:\/\/www.nytechnologist.com\/beyondthebasics\/wp-content\/uploads\/2012\/12\/Advanced-Access-12-1-2012-vacation-list_start-point.zip\">Advanced Access 12-1-2012 (vacation list_start point)<\/a><\/p>\n<p><a href=\"http:\/\/www.nytechnologist.com\/beyondthebasics\/wp-content\/uploads\/2012\/12\/Advanced-Access-12-1-2012-vacation-list_end-point.zip\">Advanced Access 12-1-2012 (vacation list_end point)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Objective:\u00a0 Show all columns and rows from a table. SQL Example 1: Start with the basic example below. Select * From T01_VacationList Objective:\u00a0 Filter rows and show all columns. SQL Example 2: Filter and show all columns.\u00a0 Also use &#8220;V&#8221; to write SQL code more compactly. Select * From T01_VacationList as V Where V.Category = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[19,21],"tags":[],"class_list":["post-218","post","type-post","status-publish","format-standard","hentry","category-advanced-microsoft-access","category-structured-query-language-sql"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2Cll0-3w","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.nytechnologist.com\/beyondthebasics\/wp-json\/wp\/v2\/posts\/218","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nytechnologist.com\/beyondthebasics\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nytechnologist.com\/beyondthebasics\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nytechnologist.com\/beyondthebasics\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nytechnologist.com\/beyondthebasics\/wp-json\/wp\/v2\/comments?post=218"}],"version-history":[{"count":13,"href":"https:\/\/www.nytechnologist.com\/beyondthebasics\/wp-json\/wp\/v2\/posts\/218\/revisions"}],"predecessor-version":[{"id":247,"href":"https:\/\/www.nytechnologist.com\/beyondthebasics\/wp-json\/wp\/v2\/posts\/218\/revisions\/247"}],"wp:attachment":[{"href":"https:\/\/www.nytechnologist.com\/beyondthebasics\/wp-json\/wp\/v2\/media?parent=218"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nytechnologist.com\/beyondthebasics\/wp-json\/wp\/v2\/categories?post=218"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nytechnologist.com\/beyondthebasics\/wp-json\/wp\/v2\/tags?post=218"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}