Home > database >  For help! Questions about oracle database code to mysql code..
For help! Questions about oracle database code to mysql code..

Time:10-15

Select


The from (
Selectvehicle vehicleid, vehicle Platenumber,
Total COUNT (devicerunning. Deviceid),
The sum (decode (Warningtypeid, 1,1,2,1,3,1,0) TypeA,
The sum (decode (Warningtypeid, 4,1,5,1,6,1,7,1,8,1,9,1,10,1,0)) TypeB,
The sum (decode (Warningtypeid, 11,1,12,1,13,1,0)) TypeC,
The sum (decode (Warningtypeid, 1, 0)) as Type1,
The sum (decode (Warningtypeid, 2, 0)) as Type2,
The sum (decode (Warningtypeid, 3, 0)) as Type3,
The sum (decode (Warningtypeid, 4, 0)) as Type4,
The sum (decode (Warningtypeid, 5, 0)) as Type5,
The sum (decode (Warningtypeid, 6, 0)) as Type6,
The sum (decode (Warningtypeid, 7, 0)) as Type7,
The sum (decode (Warningtypeid, 8, 0)) as Type8,
The sum (decode (Warningtypeid, 9, 0)) as Type9,
The sum (decode (Warningtypeid, 10, 0)) as Type10,
The sum (decode (Warningtypeid, 11, 0)) as Type11,
The sum (decode (Warningtypeid, 12, 0)) as Type12,
The sum (decode (Warningtypeid, 13, 0)) as Type13
Decode function in the code above the sum function in mysql, so try to sum (case when Warningtypeid=1 then 1 · · · · · · the when Warningtypeid=3 then 1 else 0 end) TypeA, report format error, excuse me how should change

CodePudding user response:

The
refer to the original poster qq_41606102 response:
select


The from (
Selectvehicle vehicleid, vehicle Platenumber,
Total COUNT (devicerunning. Deviceid),
The sum (decode (Warningtypeid, 1,1,2,1,3,1,0) TypeA,
The sum (decode (Warningtypeid, 4,1,5,1,6,1,7,1,8,1,9,1,10,1,0)) TypeB,
The sum (decode (Warningtypeid, 11,1,12,1,13,1,0)) TypeC,
The sum (decode (Warningtypeid, 1, 0)) as Type1,
The sum (decode (Warningtypeid, 2, 0)) as Type2,
The sum (decode (Warningtypeid, 3, 0)) as Type3,
The sum (decode (Warningtypeid, 4, 0)) as Type4,
The sum (decode (Warningtypeid, 5, 0)) as Type5,
The sum (decode (Warningtypeid, 6, 0)) as Type6,
The sum (decode (Warningtypeid, 7, 0)) as Type7,
The sum (decode (Warningtypeid, 8, 0)) as Type8,
The sum (decode (Warningtypeid, 9, 0)) as Type9,
The sum (decode (Warningtypeid, 10, 0)) as Type10,
The sum (decode (Warningtypeid, 11, 0)) as Type11,
The sum (decode (Warningtypeid, 12, 0)) as Type12,
The sum (decode (Warningtypeid, 13, 0)) as Type13
Decode function in the code above the sum function in mysql, so try to sum (case when Warningtypeid=1 then 1 · · · · · · the when Warningtypeid=3 then 1 else 0 end) TypeA, report format error, could you tell me how to change should


Should be in the case when the end structure mysql can also, but you can if you try,
The select case when c1=1 then the when c1=2 'aa' then 'bb' when c1=3 then 'cc' else 'dd' end from t1;
Select the if (c1=1, 'aa', the if (c1=2, 'bb', the if (c1=3, 'cc', 'dd'))) from t1;

CodePudding user response:

reference 1st floor lhdz_bj response:
Quote: refer to the original poster qq_41606102 response:

Select


The from (
Selectvehicle vehicleid, vehicle Platenumber,
Total COUNT (devicerunning. Deviceid),
The sum (decode (Warningtypeid, 1,1,2,1,3,1,0) TypeA,
The sum (decode (Warningtypeid, 4,1,5,1,6,1,7,1,8,1,9,1,10,1,0)) TypeB,
The sum (decode (Warningtypeid, 11,1,12,1,13,1,0)) TypeC,
The sum (decode (Warningtypeid, 1, 0)) as Type1,
The sum (decode (Warningtypeid, 2, 0)) as Type2,
The sum (decode (Warningtypeid, 3, 0)) as Type3,
The sum (decode (Warningtypeid, 4, 0)) as Type4,
The sum (decode (Warningtypeid, 5, 0)) as Type5,
The sum (decode (Warningtypeid, 6, 0)) as Type6,
The sum (decode (Warningtypeid, 7, 0)) as Type7,
The sum (decode (Warningtypeid, 8, 0)) as Type8,
The sum (decode (Warningtypeid, 9, 0)) as Type9,
The sum (decode (Warningtypeid, 10, 0)) as Type10,
The sum (decode (Warningtypeid, 11, 0)) as Type11,
The sum (decode (Warningtypeid, 12, 0)) as Type12,
The sum (decode (Warningtypeid, 13, 0)) as Type13
Decode function in the code above the sum function in mysql, so try to sum (case when Warningtypeid=1 then 1 · · · · · · the when Warningtypeid=3 then 1 else 0 end) TypeA, report format error, could you tell me how to change should


Should be in the case when the end structure mysql can also, but you can if you try,
The select case when c1=1 then the when c1=2 'aa' then 'bb' when c1=3 then 'cc' else 'dd' end from t1;
Select the if (c1=1, 'aa', the if (c1=2, 'bb', the if (c1=3, 'cc', 'dd'))) from t1;
thank you! Try your if statement can, also wrote the if statement, before and after your comparison found error because nested didn't play on the brackets (before I wrote the if eslif else, discovery also report format error ~)
  • Related