clear markdown compare help best fiddles feedback dbanow.uk
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 2805438 fiddles created (40825 in the last week).

CREATE TABLE CI_BSEG_CALC_LN ( BSEG_ID NUMBER(5), DST_ID VARCHAR(8), BILL_SQ NUMBER(7,2), AUDIT_CALC_AMT NUMBER(7,5), "BILL_SQ, MSR_PEAK_QTY_SW, DESCR_ON_BILL, VERSION, AUDIT_CALC_AMT" VARCHAR(65) );
 hidden batch(es)


INSERT INTO CI_BSEG_CALC_LN (BSEG_ID, DST_ID, BILL_SQ, AUDIT_CALC_AMT, "BILL_SQ, MSR_PEAK_QTY_SW, DESCR_ON_BILL, VERSION, AUDIT_CALC_AMT") VALUES ('12334', 'REV-WSC', '62', '6.40667', 'For 0 - 60 (Next 62.000 cubic meter) @US0.10 per cubic meter');
1 rows affected
 hidden batch(es)


INSERT INTO CI_BSEG_CALC_LN (BSEG_ID, DST_ID, BILL_SQ, AUDIT_CALC_AMT, "BILL_SQ, MSR_PEAK_QTY_SW, DESCR_ON_BILL, VERSION, AUDIT_CALC_AMT") VALUES ('12334', 'REV-WSC', '62', '64.06667', 'For 60 - 120 (Next 62.000 cubic meter) @US1.00 per cubic meter');
1 rows affected
 hidden batch(es)


INSERT INTO CI_BSEG_CALC_LN (BSEG_ID, DST_ID, BILL_SQ, AUDIT_CALC_AMT, "BILL_SQ, MSR_PEAK_QTY_SW, DESCR_ON_BILL, VERSION, AUDIT_CALC_AMT") VALUES ('12334', 'REV-WSC', '3.6', '11.16', 'For 120 - 180 (Next 3.600 cubic meter) @US3.00 per cubic meter');
1 rows affected
 hidden batch(es)


INSERT INTO CI_BSEG_CALC_LN (BSEG_ID, DST_ID, BILL_SQ, AUDIT_CALC_AMT, "BILL_SQ, MSR_PEAK_QTY_SW, DESCR_ON_BILL, VERSION, AUDIT_CALC_AMT") VALUES ('12334', 'REV_WWSC', '62', '3.20333', 'For 0 - 60 (Next 62.000 cubic meter) @US0.05 per cubic meter');
1 rows affected
 hidden batch(es)


INSERT INTO CI_BSEG_CALC_LN (BSEG_ID, DST_ID, BILL_SQ, AUDIT_CALC_AMT, "BILL_SQ, MSR_PEAK_QTY_SW, DESCR_ON_BILL, VERSION, AUDIT_CALC_AMT") VALUES ('12334', 'REV_WWSC', '62', '32.03333', 'For 60 - 120 (Next 62.000 cubic meter) @USSAR0.50 per cubic meter');
1 rows affected
 hidden batch(es)


INSERT INTO CI_BSEG_CALC_LN (BSEG_ID, DST_ID, BILL_SQ, AUDIT_CALC_AMT, "BILL_SQ, MSR_PEAK_QTY_SW, DESCR_ON_BILL, VERSION, AUDIT_CALC_AMT") VALUES ('12334', 'REV_WWSC', '3.6', '5.58', 'For 120 - 180 (Next 3.600 cubic meter) @US1.50 per cubic meter');
1 rows affected
 hidden batch(es)


INSERT INTO CI_BSEG_CALC_LN (BSEG_ID, DST_ID, BILL_SQ, AUDIT_CALC_AMT, "BILL_SQ, MSR_PEAK_QTY_SW, DESCR_ON_BILL, VERSION, AUDIT_CALC_AMT") VALUES ('11111', 'REV-WSC', '62', '6.40667', 'For 0 - 60 (Next 62.000 cubic meter) @US0.10 per cubic meter');
1 rows affected
 hidden batch(es)


INSERT INTO CI_BSEG_CALC_LN (BSEG_ID, DST_ID, BILL_SQ, AUDIT_CALC_AMT, "BILL_SQ, MSR_PEAK_QTY_SW, DESCR_ON_BILL, VERSION, AUDIT_CALC_AMT") VALUES ('11111', 'REV-WSC', '62', '64.06667', 'For 60 - 120 (Next 62.000 cubic meter) @US1.00 per cubic meter');
1 rows affected
 hidden batch(es)


INSERT INTO CI_BSEG_CALC_LN (BSEG_ID, DST_ID, BILL_SQ, AUDIT_CALC_AMT, "BILL_SQ, MSR_PEAK_QTY_SW, DESCR_ON_BILL, VERSION, AUDIT_CALC_AMT") VALUES ('11111', 'REV-WSC', '3.6', '11.16', 'For 120 - 180 (Next 3.600 cubic meter) @US3.00 per cubic meter');
1 rows affected
 hidden batch(es)


INSERT INTO CI_BSEG_CALC_LN (BSEG_ID, DST_ID, BILL_SQ, AUDIT_CALC_AMT, "BILL_SQ, MSR_PEAK_QTY_SW, DESCR_ON_BILL, VERSION, AUDIT_CALC_AMT") VALUES ('11111', 'REV_WWSC', '62', '3.20333', 'For 0 - 60 (Next 62.000 cubic meter) @US0.05 per cubic meter');
1 rows affected
 hidden batch(es)


INSERT INTO CI_BSEG_CALC_LN (BSEG_ID, DST_ID, BILL_SQ, AUDIT_CALC_AMT, "BILL_SQ, MSR_PEAK_QTY_SW, DESCR_ON_BILL, VERSION, AUDIT_CALC_AMT") VALUES ('11111', 'REV_WWSC', '62', '32.03333', 'For 60 - 120 (Next 62.000 cubic meter) @USSAR0.50 per cubic meter');
1 rows affected
 hidden batch(es)


INSERT INTO CI_BSEG_CALC_LN (BSEG_ID, DST_ID, BILL_SQ, AUDIT_CALC_AMT, "BILL_SQ, MSR_PEAK_QTY_SW, DESCR_ON_BILL, VERSION, AUDIT_CALC_AMT") VALUES ('11111', 'REV_WWSC', '3.6', '5.58', 'For 120 - 180 (Next 3.600 cubic meter) @US1.50 per cubic meter');
1 rows affected
 hidden batch(es)


SELECT BSEG_ID,DST_ID, SUM(CASE WHEN BILL_SQ >= 0 AND BILL_SQ <= 10 THEN 1 ELSE 0 END) "0-10", SUM(CASE WHEN BILL_SQ > 10 AND BILL_SQ <= 20 THEN 1 ELSE 0 END) "10> <= 20", SUM(CASE WHEN BILL_SQ > 20 THEN 1 ELSE 0 END) ">20" FROM CI_BSEG_CALC_LN GROUP BY BSEG_ID, DST_ID
BSEG_ID DST_ID 0-10 10> <= 20 >20
12334 REV-WSC 1 0 2
12334 REV_WWSC 1 0 2
11111 REV_WWSC 1 0 2
11111 REV-WSC 1 0 2
 hidden batch(es)


SELECT BSEG_ID,DST_ID, SUM(CASE WHEN res_sum >= 0 AND res_sum <= 10 THEN 1 ELSE 0 END) "0-10", SUM(CASE WHEN res_sum > 10 AND res_sum <= 20 THEN 1 ELSE 0 END) "10> <= 20", SUM(CASE WHEN res_sum > 20 THEN 1 ELSE 0 END) ">20" FROM (SELECT BSEG_ID,DST_ID, SUM(AUDIT_CALC_AMT) res_sum FROM CI_BSEG_CALC_LN GROUP BY BSEG_ID, DST_ID) t1 GROUP BY BSEG_ID, DST_ID
BSEG_ID DST_ID 0-10 10> <= 20 >20
12334 REV-WSC 0 0 1
12334 REV_WWSC 0 0 1
11111 REV_WWSC 0 0 1
11111 REV-WSC 0 0 1
 hidden batch(es)