XML in SQL

Categories: Code Problem / Data Structures and Algorithms / Recursion (32) Code Problem / Data Structures and Algorithms / Binary Search (30) Code Problem / Data Structures and Algorithms / Linked Lists (26) Code Problem / Data Structures and Algorithms / Backtracking (26) Code Problem / Data Structures and Algorithms / Stacks and Queues (25) Code Problem / Data Structures and Algorithms / Hashing (24) Databases / SQL / Backup and Recovery (19) Code Problem / Data Structures and Algorithms / Arrays and Strings (19) Databases / SQL / Database Normalization (18) Code Problem / Data Structures and Algorithms / Time Complexity (17) Databases / SQL / Locking (16) Databases / SQL / Replication (15) Databases / SQL / SQL Queries (13) Code Problem / Data Structures and Algorithms / Graphs (13) Databases / SQL / Database Security (13)  More...

Recent solutions:

Check these solutions from our community:
Databases / SQL DifficultyHard SQL
This technical problem deals with how to query XML data in SQL in order to return it in a tabular format.
About this solution: This solution is correct and uses the XML data type's built-in methods to parse the XML data, which is optimal.
Jan 30
Databases / SQL DifficultyHard SQL
Given an XML document, write a SQL query to find all the nodes with a given attribute value.
About this solution: The candidate's solution is complete and solves the problem. The candidate's approach is to use the XMLTABLE function to parse the XML document and return a table of values. The XMLTABLE function takes an XML document and a path expression as arguments. The path expression is used to extract the desired nodes from the XML document. The XMLTABLE function returns a table with a column for each node in the path expression. The XMLTABLE function is used in the FROM clause of the SQL query. The WHERE clause is used to filter the results to only include rows where the value of the attribute is equal to the desired value.
Nov 27
Databases / SQL DifficultyHard SQL
Given a table of products and their prices, write a SQL query to find the products with the highest price per unit.
About this solution: The candidate's solution is correct and demonstrates a good understanding of SQL.
Nov 26
Databases / SQL DifficultyHard SQL
Write a SQL query to find all pairs of distinct values in two columns.
About this solution: The solution above is optimal because it uses the DISTINCT keyword to remove duplicates.
Nov 22
Databases / SQL DifficultyHard SQL
This technical problem involves writing a SQL query to find the average price of all products in a database. An example product table is provided, and the expected output is the average price of all products in the table.
About this solution: This solution is complete and solves the problem. The approach is straightforward and easy to understand.
Nov 21
Databases / SQL DifficultyMedium SQL
To get customers who have made a purchase in the last 30 days, write a SQL query that returns all customers with a purchase_date within the last 30 days.
About this solution: The solution above is a good solution that demonstrates a level of completeness and solves the problem. The approach is also good, using the DATE_SUB function to subtract 30 days from the current date. This is optimal because it will always return the correct results, regardless of the current date.
Nov 18
Databases / SQL DifficultyMedium SQL
This technical problem deals with returning the value of an XPath expression from an XML document using a SQL query.
About this solution: The candidate's solution is complete and solves the problem. The candidate has used the XMLTABLE function to parse the XML document and return the value of the XPath expression.
Nov 15
Databases / SQL DifficultyMedium SQL
Given a table with two columns, this SQL query will find the number of rows where the value in the second column is greater than the value in the first column.
About this solution: The candidate's solution is correct and uses an optimal approach.
Nov 12