🔗 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