SQLkiller - AI Data Analysis Prompt Tutorial

AI Prompt Template for Writing SQL

Now we have the table structure information for the following tables, [table_schema]. I need [input your data retrieval requirement description], please output the Hive SQL code. The output should meet the following requirements: 1. Return only the SQL code block, no extra text. 2. Include necessary comments. 3. Use as few SQL code segments as possible.

Table structure example as follows:

        table_schema = {
          "user_login": {
            "table_name": "User Login Record Table",
            "columns": [
              {"column_name": "user_id", "column_meaning": "User ID"},
              {"column_name": "logtime", "column_meaning": "User login time"}
            ]
          },
          "user_order_info": {
            "table_name": "Order Information Table",
            "columns": [
              {"column_name": "order_id", "column_meaning": "Order number"},
              {"column_name": "user_id", "column_meaning": "User ID who placed the order"},
              {"column_name": "sku_id", "column_meaning": "Specific product ID purchased by the user"},
              {"column_name": "buy_time", "column_meaning": "Time when the user placed the order"}
            ]
          }
        }
      

Data retrieval requirement example as follows:

Retrieve the number of users who logged in each day, and the number of users who logged in and placed an order each day, after February 1, 2023.

Note: In addition to the example Hive, you can also specify other SQL dialects, such as Presto.

AI Prompt Template for Modifying SQL with Runtime Errors

I have the following SQL that is running with an error "[corresponding user-entered SQL]", and the error message is "[user-entered error message]". Please briefly explain the cause of the error and provide the corrected SQL. The output should meet the following requirements: only return a simple explanation and the corrected SQL, no extra text.

AI Prompt Template for Generating EXCEL Formulas

I now need [description of your requirement. Example: Output "Fail" if the data in cell A1 is less than 60, otherwise output "Pass"]. Please output the correct Excel formula to meet my needs. The output should meet the following requirements: only return the Excel formula, no extra text. Include necessary comments.

AI tools recommended for use: ChatGPT, POE, Claude, Kimi: If you need help, click here to contact me