Skip to content

fix: update SQL queries and formatting in queries.md #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 30 additions & 27 deletions queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,98 +4,101 @@

## Iteration 2

**1. Add the `solid` and `chartjs` libraries as new rows to the `jslibraries` table.**
**1. Add the `solid` and `chartjs` libraries as new rows to the `jslibraries`
table.**

<!-- Your Query Goes Here -->
INSERT INTO jslibraries (name, type, main_technology, stars, used_by, licence,
contributors, releases, release_date) VALUES ('solid', 'UI Library',
'typescript', 10700, 624, 'MIT License', 73, 194, '2011-08-13'), ('chartjs',
'Charts Library', 'javascript', 54700, 414000, 'MIT License', 377, 85,
'2011-11-02');

<br>

**2. Get all the fields of the library that was released earliest (first).**

<!-- Your Query Goes Here -->
SELECT \* FROM jslibraries ORDER BY releases ASC ;

<br>

**3. Get all the fields of the library that was released most recently (last).**

<!-- Your Query Goes Here -->

<br>
SELECT \* FROM jslibraries ORDER BY releases DeSC ; <br>

**4. All the libraries released before 2015.**

<!-- Your Query Goes Here -->
SELECT \* FROM jslibraries ORDER BY releases < 2015 ;

<br>

**5. Get the `name` and the `release_date` of the libraries without a licence.**

<!-- Your Query Goes Here -->
SELECT name, release_date FROM jslibraries WHERE licence IS NULL;

<br>

**6. Get the `name` and the `stars` from all CSS Framework libraries.**

<!-- Your Query Goes Here -->
SELECT name, stars FROM jslibraries WHERE type = 'CSS FRAMEWORK';

<br>

**7. Get the `name` of the libraries where the main technology is Typescript.**

<!-- Your Query Goes Here -->
SELECT name FROM jslibraries WHERE main_technology = 'typescript';

<br>

**8. Get the `name` and the `type` of all the libraries with more than 1000 contributors.**

<!-- Your Query Goes Here -->
**8. Get the `name` and the `type` of all the libraries with more than 1000
contributors.**

<br>
SELECT name FROM jslibraries WHERE main_technology = 'typescript'; <br>

**9. Get the total number of `stars` of all the libraries.**

<!-- Your Query Goes Here -->
SELECT stars FROM jslibraries

<br>

**10. Get the average number of `contributors` for all the libraries.**

<!-- Your Query Goes Here -->
SELECT AVG(contributors) FROM jslibraries

<br>

**11. Update the `licence` field of the libriaries without a licence to store `'unknown'` instead of `NULL`.**
**11. Update the `licence` field of the libriaries without a licence to store
`'unknown'` instead of `NULL`.**

<!-- Your Query Goes Here -->
UPDATE jslibraries SET licence = 'unknown' WHERE licence IS NULL;

<br>

**12. Update the `used_by` field of the libraries that don't have this information to store `'unknown'` instead of `NULL`.**
**12. Update the `used_by` field of the libraries that don't have this
information to store `'unknown'` instead of `NULL`.**

<!-- Your Query Goes Here -->
UPDATE jslibraries SET used_by = 'unknown' WHERE used_by IS NULL;

<br>

**13. Update all the records to capitalize the string provided in the `main_technology` field.**
**13. Update all the records to capitalize the string provided in the
`main_technology` field.**

<!-- Your Query Goes Here -->
UPDATE jslibraries SET main_technology = UPPER(main_technology);

<br>

**14. Delete all the records where `licence` is `'unknown'`.**

<!-- Your Query Goes Here -->
DELETE FROM jslibraries WHERE licence = 'unknown'

<br>

**15. Delete all the records with 10000 or less `stars`.**

<!-- Your Query Goes Here -->
DELETE FROM jslibraries WHERE stars <= 1000

<br>

**16. Delete all the records with less than 100 `releases`.**

<!-- Your Query Goes Here -->

<br>
DELETE FROM jslibraries WHERE releases <= 100 <br>