I have a list of RichPipes with the following fields:
name: String
joinTime: Long
value: Int
I want to join them sequentially using reduce. When joining the RichPipes I only want to retain one field, value, and I want it to contain the max value from the joint RichPipes. How can I do it?
Related
I'm having problem with one list.
Field X.1 is duplicated
I would like use group_by and func.max to leave only X.1 rows which have some max value.
There is not much to choose from. I would prefer timestamp.
But it is not working for me even with int field.
Would you know what I'm doing wrong.
q = self.session.query(
X.0, # object id
X.1, # these are duplicated and the output I want have max to show only max rows
X.2,
X.3,
X.3,
X.5,
X.6,
X.7,
X.8,
X.9,
X.10 # this is timestamp
).filter(x.3 == filter_value1)
q.group_by(
X.0, # object id
X.1, # these are duplicated and the output I want have max to show only max rows
X.2,
X.3,
X.3,
X.5,
X.6,
X.7,
X.8,
X.9,
func.max(X.10)) # timestamp
q.all()
I have a field where I'd like to count the number of instances the field has the max number for that given column. For example, if the max value for a given column is 20, I want to know how many 20's are in that column. I've tried the following formula but I have received a "Cannot mix aggregate and non-aggregate arguments with this function."
IF [Field1] = MAX([Field1])
THEN 1
ELSE 0
END
Try
IF ATTR([Field1]) = MAX(['Field1'])
THEN 1
ELSE 0
END
ATTR() is an aggreation which will allow you to compare aggregate and non aggregate values. As long as the value you are aggregating with ATTR() contains unique values then this won't have an impact on your data.
How do I sort a list with a secondary value - So the list is first sorted by one value then for duplicates of the first value the list is then sorted by a secondary value? Basically I need the functionality you get in SQL queries using orderby valueOne, valueTwo.
valueOne and valueTwo are both ints.
I can sort by single value using:
list.sort((a, b) => a.listValueOne.compareTo(b.ListValueOne));
I want to filter out those entries that have operation_id equal to "0".
val operations_seen_qty = parsed.flatMap(_.lift("operation_id")).toSet.size.toString
parsed is List[Map[String,String]].
How can I do it?
This is my draft, but I think that I am in contrast selecting only those entries that have operation_id equal to 0:
val operations_seen_qty = parsed.flatMap(_.lift("operation_id")).filter(p=>p.equals("0")).toSet.size.toString
The final objective is to count the number of unique operation_id values that are not equal to "0".
If I understand correctly, you only want to retain those entries whose entry id is NOT equal to "0". In this case, the function in the filter should be p=>!p.equals("0") or p=>p!="0".
Filter will retain the entries fulfill the predicate. What you did is exactly the opposite.
my table contains int columns that correspons to enum types.
E.g. the values of int column Command corresponds to this type:
public enum Commands
{
Start = 1,
End = 2
}
If I query the table and order it by Command, I get the rows with Command=Start followed by Commen=End.
Is there a way I can sort the query by the string value of the Command column, e.g. End first and Start last.
results.OrderBy(s => (Command as Commands).ToString())
But it gives me error "Only initializers, entity members, and entity navigation properties are supported".
Of course I could put the Command's string value as a column and sort by it, but we prefer using int columns for different reasons.
Thanks