question

Abhay Bajpai avatar image
0 Likes"
Abhay Bajpai asked Jason Lightfoot commented

Concatenation of Names using SQL to Update Maps

Objective: To put unique names (in a map called "PartMap") of item that need to be summoned at each station. Each station has specific items that get added on top of the flow item "Floor".


I have 8 columns. Column 1 is stationID. Column 2 is MODEL_NAME. Column 3 MODE_PART and Column 4 onwards to column 8 are for options. Options header should be concatenated to the end of Model_Part if the the value in the row for that Model_Part under an option is "1". If it is blank, then no concatenation required. The nomenclature I am trying to achieve should be "MODEL_NANE-MODEL_PART-OPTION header" (OPTION is conditional if present)

1690471248484.png

Model and Part name columns have values in all rows but not the option names. Option names have only have one value "1". Columns 3 through 10 headers are the names of the options. If that option has a value 1 against the model name, that means that option is present in the model. For example, row 1 has a model name "Model 1", part name "Floor" and under column 3 option header "Option 1", there is the number 1 means that Option 1 is present in Model 1's Part "Floor". Another example, | Model 2 | Wall | 0 | then it should display "Model 2-Wall" since The Model_Part "WALL" does not have any options.1690471151403.png


@Jason Lightfoot

ChampionHomes_V7_Abhay_1.fsm

FlexSim 23.1.2
sql queries
· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Carter Walch avatar image
1 Like"
Carter Walch answered Abhay Bajpai edited

Hi @Abhay Bajpai ,

Here is a SQL query you can use to create your table with the concatenated column:

  1. string sql = "SELECT MODEL_NAME, MODEL_PART, MODEL_NAME + '-' + MODEL_PART + '-' + \
  2. CASE \
  3. WHEN OPTION_1 = 1 THEN 'OPTION_1' \
  4. WHEN OPTION_2 = 1 THEN 'OPTION_2' \
  5. WHEN OPTION_3 = 1 THEN 'OPTION_3' \
  6. WHEN OPTION_4 = 1 THEN 'OPTION_4' \
  7. WHEN OPTION_5 = 1 THEN 'OPTION_5' \
  8. ELSE '' \
  9. END AS CONCATENATED_NAME \
  10. FROM OptionsTable";
  11. Table result=Table.query(sql);
  12. result.cloneTo(Table("temp3"));

1690478015534.png

What do you want the value to look like when multiple Option columns have a 1 value? I also changed your column headers from 'OPTION 1' to OPTION_1 to avoid errors with spaces in names in SQL


1690478015534.png (17.6 KiB)
· 19
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.