我很难弄清楚如何做到这一点,我无法很好地解释它。由于我不知道如何解释,我似乎无法通过简单的研究在网上找到答案。所以,我必须把它画出来并寻求帮助。以下是详细信息:
示例列:我的原始 SQL 查询创建了此表(特定于此问题的数据来自一个巨大的表)
示例代码:
SELECT
inventory .01 as `Item#`,
inventory .02 as `warehouse`,
inventory .03 as `qty`,
inventory .04 as `price`,
inventory .05 as `weight`,
inventory .06 as `other`
FROM
Inventory
WHERE
Inventory.other = 5
Run Code Online (Sandbox Code Playgroud)
返回这个:
Item# | warehouse | qty | price | weight | other
1 1 1 3 4 5
1 2 6 3 4 5
1 3 3 3 4 5
Run Code Online (Sandbox Code Playgroud)
我使用 group by 重写了表,使数据看起来像这样:
SELECT
inventory .01 as `Item#`,
inventory .03 as `qty (whse1)`, …Run Code Online (Sandbox Code Playgroud)