Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.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
Sorting Ampscript:desc对数据扩展名中的字段值进行排序,并将其传递给另一个变量_Sorting_Exacttarget_Ampscript - Fatal编程技术网

Sorting Ampscript:desc对数据扩展名中的字段值进行排序,并将其传递给另一个变量

Sorting Ampscript:desc对数据扩展名中的字段值进行排序,并将其传递给另一个变量,sorting,exacttarget,ampscript,Sorting,Exacttarget,Ampscript,我有一个带有6个字段的数据扩展: EmailAdress (type: EmailAdress, unique) Field1 (type: number, not nullable) Field2 (type: number, not nullable) Field3 (type: number, not nullable) Field4 (type: number, not nullable) Field5 (type: number, not nullable) Field1: 10 F

我有一个带有6个字段的数据扩展:

EmailAdress (type: EmailAdress, unique)
Field1 (type: number, not nullable)
Field2 (type: number, not nullable)
Field3 (type: number, not nullable)
Field4 (type: number, not nullable)
Field5 (type: number, not nullable)
Field1: 10
Field2: 15
Field3: 5
Field4: 1
Field5: 100
%%=ContentAreaByName("my contents\Campaigns\mainitem\@field5")=%%
%%=ContentAreaByName("my contents\Campaigns\subitem1\@field2")=%%
%%=ContentAreaByName("my contents\Campaigns\subitem2\@field1")=%%
%%=ContentAreaByName("my contents\Campaigns\subitem3\@field3")=%%
%%=ContentAreaByName("my contents\Campaigns\subitem4\@field4")=%%
我有三个目标:

1.将每个字段的值传递到ampscript变量(简单部分)

二,。根据变量的值降序排列变量,(3)将它们传递到五个ContentArea中的一个

例如,如果my字段的值为:

EmailAdress (type: EmailAdress, unique)
Field1 (type: number, not nullable)
Field2 (type: number, not nullable)
Field3 (type: number, not nullable)
Field4 (type: number, not nullable)
Field5 (type: number, not nullable)
Field1: 10
Field2: 15
Field3: 5
Field4: 1
Field5: 100
%%=ContentAreaByName("my contents\Campaigns\mainitem\@field5")=%%
%%=ContentAreaByName("my contents\Campaigns\subitem1\@field2")=%%
%%=ContentAreaByName("my contents\Campaigns\subitem2\@field1")=%%
%%=ContentAreaByName("my contents\Campaigns\subitem3\@field3")=%%
%%=ContentAreaByName("my contents\Campaigns\subitem4\@field4")=%%
然后我的五个内容区应按如下方式填充:

EmailAdress (type: EmailAdress, unique)
Field1 (type: number, not nullable)
Field2 (type: number, not nullable)
Field3 (type: number, not nullable)
Field4 (type: number, not nullable)
Field5 (type: number, not nullable)
Field1: 10
Field2: 15
Field3: 5
Field4: 1
Field5: 100
%%=ContentAreaByName("my contents\Campaigns\mainitem\@field5")=%%
%%=ContentAreaByName("my contents\Campaigns\subitem1\@field2")=%%
%%=ContentAreaByName("my contents\Campaigns\subitem2\@field1")=%%
%%=ContentAreaByName("my contents\Campaigns\subitem3\@field3")=%%
%%=ContentAreaByName("my contents\Campaigns\subitem4\@field4")=%%
将值传递给amscript值非常容易。但是,对于我有限的ampscript知识来说,desc对它们进行排序并将它们传递给appropiate@maxvar似乎有点牵强


非常感谢您的帮助

好问题。我会用一个函数取消绑定您的数据扩展,然后使用一个函数以正确的顺序检索它们。排序在AMPScript中太麻烦了

T-SQL UNPIVOT()函数在ET/SFMC上不起作用,因此您需要在查询活动中采用传统的方式:

select 
emailAddress
, field
, fieldValue
from [unpivot-test]
cross apply (
  select 'field1', field1 union all
  select 'field2', field2 union all
  select 'field3', field3 union all
  select 'field4', field4 union all
  select 'field5', field5
) c (field, fieldValue)
我有几个AMPScript查找示例。下面是LookupOrderedRows()一个:


此外,将任何未来的ET/SFMC问题张贴在上,并将其标记为
营销云
。那边有很多人在问/回答问题。

你好,亚当,谢谢你的评论!首先,我在我的查询活动中尝试了您的sql,现在我有了一个DE,它的记录数是原来的五倍。每个(以前唯一的)电子邮件地址现在在新的DE中出现5次。这是查询的预期输出吗?是。现在,您可以按电子邮件地址检索这些行,并按最小/最大标准排序。