SQL select中存在重复的ID
mysql中的选择是:SQL select中存在重复的ID,sql,pivot-table,crosstab,Sql,Pivot Table,Crosstab,mysql中的选择是: SELECT v.product_id, nome AS Produto, presentation AS Descricao, presentation AS Descricao2, name1 AS categoria, description_two AS descricao, price AS p
SELECT v.product_id,
nome AS Produto,
presentation AS Descricao,
presentation AS Descricao2,
name1 AS categoria,
description_two AS descricao,
price AS preco,
quantity AS estoque,
width,
height,
depth,
weight,
name,
referencecode,
datapostagem
FROM variant v
INNER JOIN productcategory p
ON v.product_id = p.product_id
INNER JOIN product
ON product.id = p.product_id
INNER JOIN category
ON category.id = category_id
INNER JOIN image i
ON i.product_id = p.product_id
INNER JOIN descriptiongroup D
ON D.product_id = p.product_id
INNER JOIN stock S
ON S.variant_id = v.id
INNER JOIN dimensiongroup G
ON G.variant_id = v.id
LIMIT 10
结果返回大量重复的产品标识
,如何在另一列中分离产品标识
?比如产品2,产品3,产品4
如果我做了选择,它会显示正确的表单,但只显示一个结果,我如何在我的主选择中加入下面的选择
select
product_id,
sum(case when presentation = 'Unitário = R$ 11,90 ' THEN price END) product_id1,
sum(case when presentation = '5 Peças = R$ 5,00 cada' THEN price END) product_id2,
sum(case when presentation = 'Bluesky Todas' THEN price END) product_id3
from
Variant
where
product_id = 1604
结果是:
product_id product_id1 product_id2 product_id3
1604 11.9 25 15
我怎样才能让它充满活力,让我看到所有的结果而不仅仅是一个
结果如下所示:
如上所述,遵循中的指导原则将有助于他人帮助您 从您告诉我们的内容中,我可以建议这是一个or问题:您在行中有产品ID,并且希望在列中看到它们 Excel做得很好,因为它主要是一种演示工具。Tableau和Qlik也这样做。最简单的方法是选择所需的数据(正如您所做的那样),将其复制到演示工具中,然后在那里进行交叉制表。MySQL与其他可靠的关系数据库系统一样管理数据;您应该使用某种演示工具来演示它 某些数据库(如PostgreSQL和Microsoft SQL Server)的命令行工具中的交叉选项卡功能有限,但我从未使用过它们 SQL中的数据透视表是可能的,但实际上很笨拙,因为SQL并不是用于此目的的。您可以在以下位置查看有关此的更多信息:
底线是:使用演示工具。显示示例输入和期望的与预期的输出。我希望在结果中显示类似于product_id2、product_id3、product_id4的内容,以便在选择结果中显示重复的product_id以及一些示例表数据和期望的结果。作为格式化文本,而不是图像。考虑阅读,以获得更好的答案,更快!我编辑,看那里,我在这个问题上花了两天的时间,请帮忙