Home > database >  Questions about the query sort
Questions about the query sort

Time:09-29

Now there is a table, only focus on one of the coil (30), record the time (hours and minutes on, interval for 5 minutes), flow fields, three in the first column of the chart, the second column, the second column,

Now I want to make the query results according to the below order, transverse for daily 288 for five minutes, the vertical axis for different coil, which is 288 x 30 on a table, query the how to write the results to what I want form form?

CodePudding user response:

By the way, form elements are flow

CodePudding user response:

- probably like this
The select fstr_loopgroupid, trunc (ftd_time),
The sum (case to_char (ftd_time, 'hh24mi' between '0000' and '0004' then fint_volumn else 0 end) C1,
The sum (case to_char (ftd_time, 'hh24mi' between '0005' and '0009' end then fint_volumn else 0 C2,
.
The sum (case to_char (ftd_time, 'hh24mi' between '2355' and '2359' then fint_volumn else 0 end) C288,

The from t
Group by fstr_loopgroupid trunc (ftd_time)

CodePudding user response:

Reply to this post;

CodePudding user response:

refer to the second floor wmxcn2000 response:
- probably like this
The select fstr_loopgroupid, trunc (ftd_time),
The sum (case to_char (ftd_time, 'hh24mi' between '0000' and '0004' then fint_volumn else 0 end) C1,
The sum (case to_char (ftd_time, 'hh24mi' between '0005' and '0009' end then fint_volumn else 0 C2,
.
The sum (case to_char (ftd_time, 'hh24mi' between '2355' and '2359' then fint_volumn else 0 end) C288,

The from t
Group by fstr_loopgroupid trunc (ftd_time)
haha I did send a post before, this is one small problem,
Thanks for the webmaster help, saying the statements inside can use a loop to realize,

CodePudding user response:

The
reference 4 floor baidu_36770529 reply:
haha I did send a post before, this is one small problem,
Thanks to the moderators to help, saying the statements inside can use a loop to realize,


To dynamically generate the 12 * 24 column statement; Execution, joining together into one large SQL;

CodePudding user response:

reference 5 floor wmxcn2000 reply:
Quote: refer to 4th floor baidu_36770529 response:

Ha ha I did send a post before, this is one small problem,
Thanks to the moderators to help, saying the statements inside can use a loop to realize,


To dynamically generate the 12 * 24 column statement; Execution, joining together into one large SQL;


refer to the second floor wmxcn2000 response:
- probably like this
The select fstr_loopgroupid, trunc (ftd_time),
The sum (case to_char (ftd_time, 'hh24mi' between '0000' and '0004' then fint_volumn else 0 end) C1,
The sum (case to_char (ftd_time, 'hh24mi' between '0005' and '0009' end then fint_volumn else 0 C2,
.
The sum (case to_char (ftd_time, 'hh24mi' between '2355' and '2359' then fint_volumn else 0 end) C288,

The from t
Group by fstr_loopgroupid trunc (ftd_time)
an error for the missing right parenthesis, I behind 'hh24mi' up or at the wrong, to_char cannot do variable expression?

CodePudding user response:

Case the when to_char (ftd_time, 'hh24mi) between' 0000 'and' 0004 'then fint_volumn else 0 end

CodePudding user response:

The select fstr_loopgroupid, trunc (ftd_time),
The sum (case to_char (ftd_time, 'hh24mi' between '0000' and '0004' then fint_volumn else 0 end) C1,
The sum (case to_char (ftd_time, 'hh24mi' between '0005' and '0009' end then fint_volumn else 0 C2,
.
The sum (case to_char (ftd_time, 'hh24mi' between '2355' and '2359' then fint_volumn else 0 end) C288,

The from t
Group by fstr_loopgroupid trunc (ftd_time)
  • Related