A higher resolution is required to access the IDE
- 188
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
Goal
Puzzle is meant to be a quick intro to SQL. Nothing too wild.Your inputs are a basic SQL table and a SELECT query command for each test case. Your program needs to parse these and output the correct query results.
For simplicity there are no commands to manipulate tables and only one table to select from. Nothing more advanced than basic SELECT.
Basic structure of query is as follows:
Slightly more advanced query:
ColumnValue
NOTE: sort numerical columns by their numerical value and not by their string value.
For more info on SQL syntax:
https://www.w3schools.com/sql/default.asp
Image source: https://unsplash.com/photos/PkbZahEG2Ng
Input
Line 1: A string containing the query you need to parse.
Line 2: An integer n for the number of table rows (or entries).
Line 3: A string representing a table header, containing the title of each table column, separated by space.
Following n Lines: A string representing the values for each column, separated by space.
Line 2: An integer n for the number of table rows (or entries).
Line 3: A string representing a table header, containing the title of each table column, separated by space.
Following n Lines: A string representing the values for each column, separated by space.
Output
Line 1: A string representing the header of the table, containing the selected column titles separated by space.
Following Lines: A string representing the values for each selected column, separated by space.
Following Lines: A string representing the values for each selected column, separated by space.
Constraints
2 ≤ Columns ≤ 10
2 ≤ N ≤ 30
2 ≤ N ≤ 30
Example
Input
SELECT * FROM cats 3 Name Breed McFur Peterbald Squeeky Bambino Greta Laperm
Output
Name Breed McFur Peterbald Squeeky Bambino Greta Laperm
A higher resolution is required to access the IDE