馃敆 Link: https://awsrestart.instructure.com/courses/1632/modules/items/886882

Scenario

The sales team has approached you requesting some information from the database. The information they receive from you could profit the company, and you want to ensure they get what they need. They have requested a list of books with a publish date between 2012 and 2017 that ignore the words "play", "repair", and "build" from the title of the book. Also requested was a list of all part numbers with the total or sum of the quantity sold to date.

Objectives

In this lab, you will:


Exercise 1: Select Books by Date and Ignore Specified Words

The sales team has requested a list of all books published between the years 2012 and 2017. One of the stipulations provided by your customer is to ignore the words "play", "repair", and "build" in your search.

TODO

Create a case insensitive SELECT query that returns books published between the years 2012 and 2017 that do not have "play", "repair", or "build" in their titles.

Steps

  1. In schema pane in Workbench, right click the titles table and select Select Rows = Limit 1000. You can also click on the table symbol as shown in the diagram below to accomplish the same results:

    Untitled

  2. Type SELECT partnum, bktitle, slprice, pubdate FROM pub1.titles to target only those columns from the pub1.titles table.

    Untitled

  3. After the proper columns have been selected, type WHERE*.* Press ENTER and type (pubdate between "2012-01-01" AND "2017-12-30") to filter books between those dates.

  4. Type AND. Press ENTER. Then, to filter books based on the specified keywords, type:

    (lower(bktitle) NOT LIKE "%repair%" AND
     lower(bktitle) NOT LIKE "%play%" AND
     lower(bktitle) NOT LIKE "%build%");
    

    Untitled

    <aside> 馃 Esta l铆nea de SQL es una condici贸n de filtrado que se utiliza en una cl谩usula WHERE para seleccionar registros de una tabla en funci贸n de ciertas restricciones. La condici贸n en esta l铆nea busca registros cuyo campo "bktitle" (presumiblemente el t铆tulo de un libro) no contenga las palabras "repair", "play" o "build".

    Aqu铆 hay una explicaci贸n de cada parte de la l铆nea:

    lower(bktitle): Esta parte de la l铆nea aplica la funci贸n lower() al campo bktitle. La funci贸n lower() se utiliza para convertir el texto en min煤sculas. Esto significa que el valor de bktitle se convierte en min煤sculas antes de realizar las comparaciones.

    NOT LIKE "%repair%": Esta parte de la l铆nea especifica una condici贸n de no coincidencia utilizando el operador NOT LIKE. El operador LIKE se utiliza para buscar patrones en una cadena de texto utilizando comodines. En este caso, el patr贸n "%repair%" busca cualquier valor de bktitle que contenga la palabra "repair". El s铆mbolo "%" es un comod铆n que representa cualquier cantidad de caracteres.

    AND: Este operador l贸gico se utiliza para combinar m煤ltiples condiciones y todas deben cumplirse para que se seleccione un registro. En este caso, se utiliza para combinar las tres condiciones juntas.

    lower(bktitle) NOT LIKE "%play%": Esta parte de la l铆nea especifica otra condici贸n de no coincidencia similar a la anterior, pero en este caso busca registros donde bktitle no contenga la palabra "play".

    lower(bktitle) NOT LIKE "%build%": Esta parte de la l铆nea especifica la tercera condici贸n de no coincidencia, buscando registros donde bktitle no contenga la palabra "build".

    </aside>

  5. Click the lightning bolt to execute the query.

Mi resultado

Mi resultado

Example View