I hope I'm explaining this well enough. I have table/DE a, where column a is strings and column b is numbers. I want to query table/DE a and select a record that has a specific number, and then use that to select top (number) from table/DE b and plug that result into a third table/DE.
It is my understanding that I cannot do this inside a SQL activity, and that I would need a script activity and SSJS to pull this off. But I don't think I know enough SSJS. I just need a little help.
Edit: I tried to use markdowns to explain better. I apologize if it's not the cleanest.
I copied the script from another question I saw that I thought was remotely similar and I made edits to it. I'm sure it's far from correct. I know I need 2 queries but I'm lost on how to save the result and use it in another query.
Table/DE1 Table/DE2 Table/DE3
________________ ___________ __________
| Name | Number | | Produce | | Produce |
________________ ___________ __________
| John | 1 | | Apples | | |
________________ | Oranges | __________
___________
<script runat="server">
Platform.Load("Core","1.1") ;
var queryDef1 = { Name : "Get Number from Table 1",
CustomerKey : "myQueryDef",
/*TargetUpdateType : "Overwrite", I don't think I need an UpdateType
TargetType : "DE", or a Target Type. I simply want to get that "1" value in the first table*/
int num; //would ideally be equal to the "1" in table 1
Target:{
Name:"Table 3",
CustomerKey : "Table 3"
},
QueryText : "SELECT TOP num FROM Table2"
};
var status = QueryDefinition.Add(queryDef2);
var outDE=DataExtension.Init("table 2"); // just to see the result
outDE.Rows.Add( {message:status});
String
and Column B is aNumber
"). Secondly, please give a specific example using fake sample data in both tables. Thirdly, this site exists to help you, not write code or implementations for you. So no matter how badly your SSJS might be, that's OK - try it, and then come back with what specifically you've tried & what issues or errors you have.