{"id":24021111,"url":"https://github.com/zipcodecore/maven.spring-sql.queryingpersons","last_synced_at":"2026-03-12T12:02:58.998Z","repository":{"id":79470381,"uuid":"123765843","full_name":"ZipCodeCore/Maven.Spring-SQL.QueryingPersons","owner":"ZipCodeCore","description":null,"archived":false,"fork":false,"pushed_at":"2018-03-13T05:02:11.000Z","size":6,"stargazers_count":0,"open_issues_count":32,"forks_count":32,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-15T21:39:31.364Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZipCodeCore.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-04T07:13:44.000Z","updated_at":"2022-02-03T18:57:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"6cd26b6f-bec7-43be-9ae7-f04bd30660ee","html_url":"https://github.com/ZipCodeCore/Maven.Spring-SQL.QueryingPersons","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ZipCodeCore/Maven.Spring-SQL.QueryingPersons","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZipCodeCore%2FMaven.Spring-SQL.QueryingPersons","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZipCodeCore%2FMaven.Spring-SQL.QueryingPersons/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZipCodeCore%2FMaven.Spring-SQL.QueryingPersons/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZipCodeCore%2FMaven.Spring-SQL.QueryingPersons/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZipCodeCore","download_url":"https://codeload.github.com/ZipCodeCore/Maven.Spring-SQL.QueryingPersons/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZipCodeCore%2FMaven.Spring-SQL.QueryingPersons/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30425505,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T09:20:56.688Z","status":"ssl_error","status_checked_at":"2026-03-12T09:20:13.792Z","response_time":114,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-08T12:38:48.840Z","updated_at":"2026-03-12T12:02:58.945Z","avatar_url":"https://github.com/ZipCodeCore.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SQL\n\nThe following lab is to be completed using the H2 Console. \n\nTo get to the console, start your application like any normal Spring app, and go to\n`localhost:8080/console` in a browser.  Your defaults should be fine, but just to be safe the following are the settings\nyou should use for the login:\n* Driver Class:`org.h2.Driver`\n* JDBC URL:`jdbc:h2:mem:testdb`\n* User Name:`sa`\n* Password:{leave blank}\n\nNOTE:\nThe schema for all the tables is in `src/main/resources/schema-h2.sql` and can be viewed from the H2 console.\nDon't submit any changes to the schema file.  And, in all reality, you shouldn't be doing anything in there outside of\nexperimenting for your own curiosity.\n\n## Guided Walkthrough\n\nProceed through the sections below, testing out the queries shown and observing the result. \nFeel free to experiment with your own variations on these queries. \nThis will help to build your familiarity with the process of working with SQL queries.\n\n#### Insert people into People table\n\n```SQL\nINSERT INTO people (last_name, first_name, mobile, birthday)\nVALUES ('Smith', 'John', '230-4293', '1973-01-23');\n```\n\nAfter doing that insert, go ahead and run all the statements in the `data-h2.sql` file.  That should build out your\ndatabase enough to get started.  Feel free to add more people, though.\n\nMy suggestion for the following stuff is, in the H2 console, leave the first line as a `SELECT *` from whatever tables\nyou're querying.  Then, after that, run your queries.  That way you can compare the results of your query with the \ndata in the table.\n\n#### Selecting all rows from table \n\n```SQL\nSELECT * FROM people;\n```\n\n#### Updating rows\n\nUpdate firstname for person whose id is 1\n\n```SQL\nUPDATE people SET first_name = 'Tony' WHERE id = 1;\n```\n\nUpdate mobile where last names are Smith\n\n```SQL\nUPDATE people SET mobile = '152-9854' WHERE last_name = 'Smith';\n```\n\nUpdate multiple columns with multiple conditions\n\n```SQL\nUPDATE people SET birthday = '1955-01-25' \nWHERE last_name = 'Smith' \nAND id = 4;\n```\n\n```SQL\nUPDATE people SET mobile = '333-3333', last_name = 'Johnson' \nWHERE first_name = 'Noelle' OR first_name = 'Raj';\n```\n\n#### Basic Functions\n\n```SQL\nSELECT * FROM people;\n```\n\n```SQL\nSELECT COUNT(homenumber) FROM homes;\n```\n\n```SQL\nSELECT homenumber FROM homes WHERE id = 1;\n```\n\n```SQL\nSELECT COUNT(*) FROM homes;\n```\n\n```SQL\nSELECT COUNT(DISTINCT last_name) FROM people;\n```\n\n```SQL\nSELECT  SUM(id), AVG(id) FROM people;\n```\n\n```SQL\nSELECT SUM(id) AS sum, AVG(id) AS avg FROM people;\n```\nNotice the difference in the returned table with the aliases?\n\n```SQL\nSELECT MIN(birthday) FROM people;\n```\n\n#### Strings\n\n```SQL\nSELECT UPPER (first_name), LOWER(last_name) FROM people;\n```\n\n```SQL\nSELECT REPLACE(last_name, 'a', '1') FROM people;\n```\n\n```SQL\nSELECT last_name FROM people;\n```\n\n```SQL\nINSERT INTO people (first_name, last_name, mobile) \nVALUES ('Otto', 'Von Count', '656-6548');\n```\n\n```SQL\nSELECT CONCAT(first_name, last_name) FROM people\nWHERE last_name = 'Smith';\n```\n\n```SQL\nSELECT CONCAT(first_name, ' ', last_name) \nFROM people \nWHERE last_name = 'Smith';\n```\n\n```SQL\nSELECT CONCAT_WS(' ',first_name, last_name, mobile) \nFROM people WHERE last_name= 'Smith';\n```\n\n```SQL\nSELECT homenumber, LEFT(homenumber, 3), RIGHT(homenumber, 2) FROM homes;\n```\n\n```SQL\nSELECT LENGTH(address), CHAR_LENGTH(address) FROM homes;\n```\n\n#### Compare\n\n```SQL\nSELECT first_name, last_name, YEAR(birthday) FROM people WHERE birthday \u003e= '1970-07-06' AND birthday\u003c='1987-07-06';\n```\n\n```SQL\nSELECT first_name, birthday FROM people WHERE first_name='Thomas' OR first_name='Raj' OR first_name='Sheeri';\n```\n\n```SQL\nSELECT first_name, birthday FROM people WHERE first_name IN ('Noelle', 'Thomas', 'Raj');\n```\n\n#### Wild Cards\n\n```SQL\nSELECT first_name FROM people WHERE RIGHT(first_name,1)='e';\n```\n\n```SQL\nSELECT first_name FROM people WHERE first_name LIKE '%j'; \n```\n\n```SQL\nSELECT first_name FROM people WHERE first_name LIKE '%o%';\n```\n\n```SQL\nSELECT first_name FROM people WHERE first_name NOT LIKE '%o%';\n```\n\n```SQL\nSELECT COUNT(*) FROM people;\n```\n\n```SQL\nSELECT last_name, COUNT(*) FROM people GROUP BY last_name;\n```\n\n```SQL\nSELECT last_name, GROUP_CONCAT(mobile) FROM people GROUP BY last_name;\n```\n\n```SQL\nSELECT last_name, GROUP_CONCAT(mobile SEPARATOR ' and ') FROM people GROUP BY last_name;\n```\n\n```SQL\nSELECT last_name, GROUP_CONCAT(mobile SEPARATOR ' and ') FROM people GROUP BY last_name  HAVING COUNT(*)\u003e1;\n```\n\n```SQL\nSELECT last_name, GROUP_CONCAT(mobile SEPARATOR ' and ') FROM people WHERE last_name != 'Cabral' GROUP BY last_name  HAVING COUNT(*)\u003e1;\n```\n\n#### Sorting \n\n```SQL\nSELECT first_name, birthday FROM people ORDER BY birthday;\n```\n\n```SQL\nSELECT first_name, birthday FROM people ORDER BY birthday DESC;\n```\n\n```SQL\nSELECT first_name, last_name FROM people ORDER BY last_name, first_name;\n```\n\n```SQL\nSELECT first_name, birthday FROM people ORDER BY birthday DESC LIMIT 3;\n```\n\n```SQL\nSELECT first_name, MONTHNAME(birthday) as mon, birthday FROM people ORDER BY MONTH(birthday);\n```\n\n```SQL\nSELECT last_name, COUNT(*) FROM  people GROUP BY last_name;\n```\n\n```SQL\nSELECT last_name, COUNT(*) FROM  people GROUP BY last_name ORDER BY NULL;\n```\n\n#### Inserting and Replacing Records\n\n```SQL\nINSERT INTO people (first_name, last_name, birthday, home_id)\nVALUES ('John', 'Smith', '1998-04-07', 4),\n('Maya', 'Wasserman' , NULL, 4),\n('Paul', 'Thompson', '1996-05-27', 1);\n```\n\n#### Deleting\n\n```SQL\nDELETE FROM people WHERE first_name='Maya';\n```\n\n```SQL\nSELECT * FROM people;\n```\n\n#### JOIN\n\n```SQL\nINSERT INTO people (first_name, last_name, birthday)\nVALUES ('Eli', 'Kramer', '1984-01-15');\n```\n\t\n\t\n```SQL\nSELECT * FROM people;\n```\n\n```SQL\nSELECT * FROM homes;\n```\n\n```SQL\nSELECT p.first_name, h.address \nFROM people p\nINNER JOIN homes h on (p.home_id = h.id);\n```\n\n```SQL\nSELECT first_name, last_name\nFROM people p\nINNER JOIN homes h on (p.home_id = h.id)\nWHERE p.HOME_ID = 1;\n```\n\n```SQL\nSELECT p.*, h.address, h.homenumber\nFROM people p\nINNER JOIN homes h  on (p.home_id = h.id)\nWHERE p.first_name  LIKE '%e%';\n```\n\n##### Exercise:\n\nDevise a report:\n\nShow all the people in your address table, only if you know their birthday.\n\nShow their name, address and birthday ordered by birthday month, so January birthdays are first.\n\nDevise a report:\n\nOutput all information for all people and their home information\n\n\n## Mini Movie Database\n\nOnce you have figured out the correct queries for each step, \nsave a copy in a file called `src/main/resources/script.sql`. This will be how you submit this assignment. \nIf at any time you need to reset the database, you can restart your Spring Boot server.\n\nAdd the following movies to the `movies` table using an insert statement:\n\n| Title | Runtime | Genre | IMDB Score | Rating |\n| ----- | ------- | ----- | ----------- | ----- |\n| Howard the Duck | 110 | Sci-Fi | 4.6 | PG |\n| Lavalantula | 83 | Horror | 4.7 | TV-14 |\n| Starship Troopers | 129 | Sci-Fi | 7.2 | PG-13 |\n| Waltz With Bashir | 90 | Documentary | 8.0 | R |\n| Spaceballs | 96 | Comedy | 7.1 | PG |\n| Monsters Inc. | 92 | Animation | 8.1 | G |\n\nAdd a few more movies of your choosing.\n\nCreate a query to find all movies in the Sci-Fi genre.\n\nCreate a query to find all films that scored at least a 6.5 on IMDB\n\nFor parents who have young kids, but who don't want to sit through long children's movies, \ncreate a query to find all of the movies rated G or PG that are less than 100 minutes long.\n\nCreate a query to show the average runtimes of movies scoring below a 7.5 on imdb, grouped by their respective genres.\n\nThere's been a data entry mistake; Starship Troopers is actually rated R, not PG-13. \nCreate a query that finds the movie by its title and changes its rating to R.\n\nShow the ID number and rating of all of the Horror and Documentary movies in the database. Do this in only one query.\n\nThis time let's find the average, maximum, and minimum IMDB score for movies of each rating.\n\nThat last query isn't very informative for ratings that only have 1 entry. \nUse a `HAVING COUNT(*) \u003e 1` clause to only show ratings with multiple movies showing.\n\nLet's make our movie list more child-friendly. Delete all entries that have a rating of R. \nRemember to record your query in `script.sql`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzipcodecore%2Fmaven.spring-sql.queryingpersons","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzipcodecore%2Fmaven.spring-sql.queryingpersons","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzipcodecore%2Fmaven.spring-sql.queryingpersons/lists"}