in reply to Re^2: perl sql to separate and sort the column separately?
in thread perl sql to separate and sort the column separately?
Your program and example output do not help us. Please see SSCCE for how to create an example that allows us to reproduce your problem.
From looking at your data, you seem to want to sort your list according to two criteria at the same time. This makes no sense.
Create two SQL queries and have the sorting there, according to the order you need. Then run each query separately.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: perl sql to separate and sort the column separately?
by huck (Prior) on Apr 12, 2017 at 10:44 UTC | |
Create two SQL queries and have the sorting there, according to the order you need. Then run each query separately. I disagree, if only on a technicality. Back to the idea that these are statistics from a batch scheduler, the chance that the underlying data may have changed between the separate query runs is not zero. Instead i would run one select so there is just a single select query cursor instance, and sort the data separately in perl as in
Since they included the json producing code for the creating of the pie charts, i have done so as well. That also explains why they want the separate sorts. To also add to the incomplete specs in the OP, notice how what was once called the others row has become the added row, yet that is not exhibited in the expected output. cheap::mysqls is a module in my private library that allows me to easily connect to my mysql and sqlite databases. you may use whatever method you like to connect to yours instead. | [reply] [d/l] |
by poj (Abbot) on Apr 12, 2017 at 13:50 UTC | |
Surely order by data1+data2 gives the same top 5 names just sorted differently whereas if you do separate queries the top 5 names might be different. To do both in 1 query I guess you could do something complicated like this poj | [reply] [d/l] |
by huck (Prior) on Apr 12, 2017 at 13:59 UTC | |
if 50 jobs were dumped into the queue system in-between runs of the separate queries the results would be quite different.
the sort on the sum seemed to be to list the queues with the largest combined total, but then to sort each sublist by the elements in run/pending separately For each considered totally separate, if it were me, id just do it all in perl. Result
| [reply] [d/l] [select] |