Avatar

Organizations

3 results for 组合查询 & 指定选取
  • Table: Tree

    Column NameType
    idint
    p_idint

    id is the primary key column for this table. Each row of this table contains information about the id of a node and the id of its parent node in a tree. The given structure is always a valid tree.

    Each node in the tree can be one of three types:

    • “Leaf”: if the node is a leaf node.
    • “Root”: if the node is the root of the tree.
    • “Inner”: If the node is neither a leaf node nor a root node.

    Write an SQL query to report the type of each node in the tree.

    Return the result table ordered by id in ascending order.

    The query result format is in the following example.

  • Table: Products

    Column NameType
    product_idint
    store1int
    store2int
    store3int

    product_id is the primary key for this table. Each row in this table indicates the product’s price in 3 different stores: store1, store2, and store3. If the product is not available in a store, the price will be null in that store’s column.

    Write an SQL query to rearrange the Products table so that each row has (product_id, store, price). If a product is not available in a store, do not include a row with that product_id and store combination in the result table.

    Return the result table in any order.

    The query result format is in the following example.

  • Table: Employees

    Column NameType
    employee_idint
    namevarchar

    employee_id is the primary key for this table. Each row of this table indicates the name of the employee whose ID is employee_id.

    Table: Salaries

    Column NameType
    employee_idint
    salaryint

    employee_id is the primary key for this table. Each row of this table indicates the salary of the employee whose ID is employee_id.

    Write an SQL query to report the IDs of all the employees with missing information. The information of an employee is missing if:

    • The employee’s name is missing, or
    • The employee’s salary is missing.

    Return the result table ordered by employee_id in ascending order.

    The query result format is in the following example.