2023-12-09 18:53:53 +08:00
{
"data" : {
"question" : {
"questionId" : "1278" ,
"questionFrontendId" : "1164" ,
"boundTopicId" : null ,
"title" : "Product Price at a Given Date" ,
"titleSlug" : "product-price-at-a-given-date" ,
"content" : "<p>Table: <code>Products</code></p>\n\n<pre>\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| product_id | int |\n| new_price | int |\n| change_date | date |\n+---------------+---------+\n(product_id, change_date) is the primary key (combination of columns with unique values) of this table.\nEach row of this table indicates that the price of some product was changed to a new price at some date.</pre>\n\n<p> </p>\n\n<p>Write a solution to find the prices of all products on <code>2019-08-16</code>. Assume the price of all products before any change is <code>10</code>.</p>\n\n<p>Return the result table in <strong>any order</strong>.</p>\n\n<p>The result format is in the following example.</p>\n\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> \nProducts table:\n+------------+-----------+-------------+\n| product_id | new_price | change_date |\n+------------+-----------+-------------+\n| 1 | 20 | 2019-08-14 |\n| 2 | 50 | 2019-08-14 |\n| 1 | 30 | 2019-08-15 |\n| 1 | 35 | 2019-08-16 |\n| 2 | 65 | 2019-08-17 |\n| 3 | 20 | 2019-08-18 |\n+------------+-----------+-------------+\n<strong>Output:</strong> \n+------------+-------+\n| product_id | price |\n+------------+-------+\n| 2 | 50 |\n| 1 | 35 |\n| 3 | 10 |\n+------------+-------+\n</pre>\n" ,
"translatedTitle" : null ,
"translatedContent" : null ,
"isPaidOnly" : false ,
"difficulty" : "Medium" ,
2023-12-09 19:57:46 +08:00
"likes" : 710 ,
2023-12-09 18:53:53 +08:00
"dislikes" : 179 ,
"isLiked" : null ,
"similarQuestions" : "[]" ,
"exampleTestcases" : "{\"headers\":{\"Products\":[\"product_id\",\"new_price\",\"change_date\"]},\"rows\":{\"Products\":[[1,20,\"2019-08-14\"],[2,50,\"2019-08-14\"],[1,30,\"2019-08-15\"],[1,35,\"2019-08-16\"],[2,65,\"2019-08-17\"],[3,20,\"2019-08-18\"]]}}" ,
"categoryTitle" : "Database" ,
"contributors" : [ ] ,
"topicTags" : [
{
"name" : "Database" ,
"slug" : "database" ,
"translatedName" : null ,
"__typename" : "TopicTagNode"
}
] ,
"companyTagStats" : null ,
"codeSnippets" : [
{
"lang" : "MySQL" ,
"langSlug" : "mysql" ,
"code" : "# Write your MySQL query statement below\n" ,
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "MS SQL Server" ,
"langSlug" : "mssql" ,
"code" : "/* Write your T-SQL query statement below */\n" ,
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "Oracle" ,
"langSlug" : "oraclesql" ,
"code" : "/* Write your PL/SQL query statement below */\n" ,
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "Pandas" ,
"langSlug" : "pythondata" ,
"code" : "import pandas as pd\n\ndef price_at_given_date(products: pd.DataFrame) -> pd.DataFrame:\n " ,
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "PostgreSQL" ,
"langSlug" : "postgresql" ,
"code" : "-- Write your PostgreSQL query statement below\n" ,
"__typename" : "CodeSnippetNode"
}
] ,
2023-12-09 19:57:46 +08:00
"stats" : "{\"totalAccepted\": \"77.1K\", \"totalSubmission\": \"137.8K\", \"totalAcceptedRaw\": 77074, \"totalSubmissionRaw\": 137826, \"acRate\": \"55.9%\"}" ,
2023-12-09 18:53:53 +08:00
"hints" : [ ] ,
"solution" : {
"id" : "1621" ,
"canSeeDetail" : true ,
"paidOnly" : false ,
"hasVideoSolution" : false ,
"paidOnlyVideo" : true ,
"__typename" : "ArticleNode"
} ,
"status" : null ,
"sampleTestCase" : "{\"headers\":{\"Products\":[\"product_id\",\"new_price\",\"change_date\"]},\"rows\":{\"Products\":[[1,20,\"2019-08-14\"],[2,50,\"2019-08-14\"],[1,30,\"2019-08-15\"],[1,35,\"2019-08-16\"],[2,65,\"2019-08-17\"],[3,20,\"2019-08-18\"]]}}" ,
"metaData" : "{\"mysql\": [\"Create table If Not Exists Products (product_id int, new_price int, change_date date)\"], \"mssql\": [\"Create table Products (product_id int, new_price int, change_date date)\"], \"oraclesql\": [\"Create table Products (product_id int, new_price int, change_date date)\", \"ALTER SESSION SET nls_date_format='YYYY-MM-DD'\"], \"database\": true, \"name\": \"price_at_given_date\", \"pythondata\": [\"Products = pd.DataFrame([], columns=['product_id', 'new_price', 'change_date']).astype({'product_id':'Int64', 'new_price':'Int64', 'change_date':'datetime64[ns]'})\"], \"postgresql\": [\"\\nCreate table If Not Exists Products (product_id int, new_price int, change_date date)\"], \"database_schema\": {\"Products\": {\"product_id\": \"INT\", \"new_price\": \"INT\", \"change_date\": \"DATE\"}}}" ,
"judgerAvailable" : true ,
"judgeType" : "large" ,
"mysqlSchemas" : [
"Create table If Not Exists Products (product_id int, new_price int, change_date date)" ,
"Truncate table Products" ,
"insert into Products (product_id, new_price, change_date) values ('1', '20', '2019-08-14')" ,
"insert into Products (product_id, new_price, change_date) values ('2', '50', '2019-08-14')" ,
"insert into Products (product_id, new_price, change_date) values ('1', '30', '2019-08-15')" ,
"insert into Products (product_id, new_price, change_date) values ('1', '35', '2019-08-16')" ,
"insert into Products (product_id, new_price, change_date) values ('2', '65', '2019-08-17')" ,
"insert into Products (product_id, new_price, change_date) values ('3', '20', '2019-08-18')"
] ,
"enableRunCode" : true ,
"enableTestMode" : false ,
"enableDebugger" : false ,
"envInfo" : "{\"mysql\": [\"MySQL\", \"<p><code>MySQL 8.0</code>.</p>\"], \"mssql\": [\"MS SQL Server\", \"<p><code>mssql server 2019</code>.</p>\"], \"oraclesql\": [\"Oracle\", \"<p><code>Oracle Sql 11.2</code>.</p>\"], \"pythondata\": [\"Pandas\", \"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0</p>\"], \"postgresql\": [\"PostgreSQL\", \"<p>PostgreSQL 16</p>\"]}" ,
"libraryUrl" : null ,
"adminUrl" : null ,
"challengeQuestion" : null ,
"__typename" : "QuestionNode"
}
}
}