Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 两个类别折叠为一行_Amazon Web Services_Amazon Redshift - Fatal编程技术网

Amazon web services 两个类别折叠为一行

Amazon web services 两个类别折叠为一行,amazon-web-services,amazon-redshift,Amazon Web Services,Amazon Redshift,我有两行,像这样: 我想编写一个SQL查询,将两行折叠为一行,如下所示: 有人对如何做到这一点有想法吗 可能是这样的: SELECT first_name, last_name, business_name, trade, date_submit, MAX(CASE WHEN insurer = 'Progressive' THEN status END) as status_progressive, MAX(CASE WHEN insurer = 'Travel

我有两行,像这样:

我想编写一个SQL查询,将两行折叠为一行,如下所示:


有人对如何做到这一点有想法吗

可能是这样的:

SELECT
  first_name,
  last_name,
  business_name,
  trade,
  date_submit,
  MAX(CASE WHEN insurer = 'Progressive' THEN status END) as status_progressive,
  MAX(CASE WHEN insurer = 'Travelers' THEN status END) as status_travelers
FROM table
GROUP BY first_name, last_name, business_name, trade, date_submit

我没有测试它,但这应该给你一个概念。这里没有什么是Amazon Redshift独有的。

连接行的标准是什么——相同的前5列?这样的匹配是否总是有两行(不多也不少)?会有一行或两行,但不会超过两行