I want the following output result, but it comes out when ‘DECODE’ is not recognized as a built-in function name. What is the best way to avoid it?
T_CD SUM (NBIK)
SELECT T_CD, SUM (NBIK) FROM FROM (SELECT E_D, T_CD, DECODE (T_KB, '0', (NBIK), (NBIK) * -1) AS NBIK FROM R_MYI WHERE E_D = '20150721' AND E_FLG = '9' AND E_FLG = '0' ) group by T_CD order by T_CD
I rewrote it in case, but it is displayed if there is an inappropriate syntax near ‘)’.
SELECT T_CD, SUM (NBIK) FROM FROM (SELECT E_D, T_CD, (CASE WHEN T_KB = 0 THEN NBIK ELSE (NBIK) * -1 END ) AS NBIK FROM R_MYI WHERE E_D = '20150721' AND E_FRG = '9' AND E_FLG = '0' ) group by T_CD order by T_CD
A5: SQL Mk-2
Answer # 1
Please use CASE.
By the wayNvlIs COALESCE.
If you modify the SQL, it will be as follows.
select t_cd, sum (nbik * case when t_kb = 0 then 1 else -1 end) from r_myi where e_d = '20150721' and e_flg = '9' and e_flg = '0' group by t_cd order by t_cd
e_flg = '9' and e_flg = '0'Is inconsistent, so please review the description.
Answer # 2
SQL ServerCannot be used with.
CASE expressionPlease rewrite with.
decode case convert
- sql server - i want to restore with the sql command
- sql server - i want to set a flag using a case statement
- i want to aggregate with sql
- sql server - i want to know the whole flow when writing sql
- sql server - i want to pass ":" from a batch file to a sql statement
- sql server - what is "$ip" and "$port" in "php artisan serve --host=$ip --port=$port"?
- i want to detect a ball with python+opencv
- i want to find the sql id
- i want to run c++ with vscode
- i want to save pdf with name with python selenium
- [sql server] how can i register data that does not have a screen?
- regarding the case where the sql server session remains (in the usage monitor of management studio)
- i want to read xml with python asynchronously
- typescript - i want to use axios with nuxtjs to get data from an api
- html - i want to add color with css
- i want to make a pyramid with python
- sql - i want to add a cumulative value
- mysql - i want to make a calendar with a database
- When changing the language, the SQL Developer application is collapsed
- sql : How to get a sheet of separated by commas values of the column, if the length exceeds 4000? ORA-01489: Result of String
- sql : Is there a mistake in the task?
- Mysql INSERT IGNORE equivalent
- sql : What is the basic idea of the Logging /Nologing option when creating bd objects?
- sql : How to calculate for recording count months from the moment of inserting to a given date?
- How to create a recursive query SQL Oracle?
- sql : Reducing table size without deleting data
- mysql : How to withdraw the number of people in each SQL Department
- How to transfer several parameters through the string permanent substitution in SQL SCC