I have a table that has the following schema:
DATA | CAUSE_1 | TIME_1 | CAUSE_2 | TIME_2 | CAUSE_3 | TIME_3
The CAUSE.* field (VarChar) can not contain any string, and if so, the field TIME.* is 0.
I’m trying to create a query, but unfortunately without success, where I would have the result display in this form:
CAUSE | TOT_TIME | N_RIPET_CAUSE,
where:
- In
CAUSEI have a list of what is contained inCAUSE_1 ... CAUSE_3, - In
TOT_TIMEthe sum of the values inTIME_1 ... TIME_3, - In
N_RIPET_CAUSEthe number of repetitions of eachCAUSE.
I hope I explained.
try this
SEE SQLFIDDLE DEMO
EDIT.
try this
SQL DEMO HERE
EDIT:
try this due to your need
DEMO SQL FIDDLE