How to write such SQL? How to do this SQL

Updated on technology 2024-04-09
5 answers
  1. Anonymous users2024-02-07

    select city, sum(nvl(,0)) number of disconnection alarms, sum(nvl(,0)) number of alarm exceeding the standard, sum(nvl(,0)) number of abnormal alarms.

    from bf_biz_code_ a,eps_base_info_ b,emo_alarm_statistic_ c

    where ='46140'

    and substr(,1,4) = substr(,1,4)and to_char(,'yyyy') ='2012'

    andgroup by ;

  2. Anonymous users2024-02-06

    Use the left to join: select city, sum( number of disconnection alarms, sum( number of over-standard alarms, sum( number of abnormal alarms.

    from bf_biz_code_ a inner joineps_base_info_ b

    on substr(,1,4) = substr(,1,4)left outer join emo_alarm_statistic_ c

    on =and to_char(,'yyyy') ='2012'

    where ='46140'

    group by ;

  3. Anonymous users2024-02-05

    The implementation of MySQL, the reference example is as follows, if there is any inappropriateness, please advise!

  4. Anonymous users2024-02-04

    distinct book number, book name, **, from book where **》20

    b.Order number, sum(b..)quantity) from order a, order detail b where a

    Order number=bOrder number and ausername='Zhang San' group by b.

    Order number. b.Order number, cTitle of the book, c

    ** from order a, order detail b, book c where aOrder number=bOrder number and b

    ISBN = CISBN and Ausername='Li Si'

  5. Anonymous users2024-02-03

    This is not a simple SQL but a trigger (inside the trigger is a PLSQL block, with judgment).

    The trigger condition is after insert b, that is, after the b table is entered.

    For convenience, it is recommended to add a total cost field to the newly created table to make it easier to calculate.

    1) You need to query whether table A has been entered, (I don't know the order of your input, if you can make sure that A is earlier than B, then you don't need to query whether table A has been entered.) This is relatively simple, as long as the tracking number exists, and if it exists, then continue to execute.

    2) Find the corresponding student number in this table, if not, then insert.

    3) Judge the amount, which is what you said about 1000, 2000, 10000, if yes, then update. The way of judging is also simple, if the original student number does not exist, then judge directly, and if it exists, then use the original to add this time. The judging conditions are as follows:

    The original cost < 1000 and the original cost + this cost 1000, and the other two judgments are similar to this. If the judgment is successful, then update, otherwise do not change.

    Personally, I can think of this method, but the specific needs some experiments, I haven't been able to write it directly, and it must be modified, there is no environment here, you can only change it yourself.

Related questions
7 answers2024-04-09

Summation statements in SQL are divided into vertical summary statements and horizontal summary statements. >>>More

4 answers2024-04-09

select

from[Table name]. >>>More

13 answers2024-04-09

For example, the name of your table is a

select a.Name, aGrades as Language, BGrades as Mathematics. >>>More

4 answers2024-04-09

Optimize SQL queries:How to write high-performance SQL statements. >>>More

10 answers2024-04-09

select * from (select top size * from (select top size*page a.*,from table1 as a join table2 as b on = where = 1 order by order by desc) order by >>>More