Inserisci in un elenco i valori di una tabella con condizioneHo questa tabella:
dovere | valori
0 | 1638
1 | 618
2 | 486
3 | 9418
0 | 654
1 | 791
2 | 1398
3 | 4836
...
E voglio mettere in un elenco, tutti i valori in cui il dut è 0, quindi avere questo: list = { 1638, 654 }
Che sintassi usata?
Tabella datiRe: Inserisci in un elenco i valori di una tabella con condizioneIl mio metodo preferito è usare Indicizzazione tabella dati con Loc, ma ci sono molti altri modi per farlo
Names Default To Here(1);
dt = New Table("Untitled",
Add Rows(8),
New Column("dut", Numeric, "Continuous", Format("Best", 12), Set Values([0, 1, 2, 3, 0, 1, 2, 3])),
New Column("value", Numeric, "Continuous", Format("Best", 12), Set Values([1638, 618, 486, 9418, 654, 791, 1398, 4836]))
);
zero_rows = Loc(dt[0, "dut"], 0);
list_of_values = dt[zero_rows, "value"]; // and you can convert this to list with As List();
Re: Inserisci in un elenco i valori di una tabella con condizioneEcco un altro approccio alla stessa soluzione
Names Default To Here(1);
dt = New Table("Untitled",
Add Rows(8),
New Column("dut", Numeric, "Continuous", Format("Best", 12), Set Values([0, 1, 2, 3, 0, 1, 2, 3])),
New Column("value", Numeric, "Continuous", Format("Best", 12), Set Values([1638, 618, 486, 9418, 654, 791, 1398, 4836]))
);
theList = As List( :value[dt << get rows where( :dut == 0 )] );
Show( theList );
theList = as list(:value[dt<<get rows where(:dut == 0)])
/*:
{1638, 654}