SQL乘法表
列印9*9乘法表
正三角
倒三角
正三角
-
with
-
t as
-
(
-
select level as n from dual connect by level<=9
-
)
-
select sys_connect_by_path(
-
lpad(b.n,2,' ')
-
||'*'
-
||lpad(a.n,2,' ')
-
||'='
-
||lpad(a.n*b.n,2,' '),'|') as result
-
from t a,t b
-
where level=a.n
-
start with b.n=1
-
connect by a.n=prior a.n
- and b.n=prior b.n+1;
-
set pagesize 200;
-
set linesize 400;
-
col result format a100;
-
with t as
-
(
-
select level as n from dual connect by level<=9
-
)
-
select
-
lpad(
-
substr(
-
sys_connect_by_path(lpad(a.n,2,' ')
-
||'*'
-
||lpad(b.n,2,' ')
-
||'='
-
||lpad(a.n*b.n,2,' '),
-
'|'
-
),
-
instr(
-
sys_connect_by_path(lpad(a.n,2,' ')
-
||'*'
-
||lpad(b.n,2,' ')
-
||'='
-
||lpad(a.n*b.n,2,' '),
-
'|'
-
),
-
'|',-1,a.n
-
)
-
),81,' '
-
) as result
-
from t a,t b
-
where level=9
-
start with b.n=9
-
connect by a.n=prior a.n and b.n=prior b.n-1
- order by a.n desc,b.n desc;
-
WITH num AS
-
( SELECT rownum r FROM dual CONNECT BY level<=9
-
)
-
SELECT listagg(y.r
-
||'*'
-
||x.r
-
||'='
-
||
-
CASE
-
WHEN x.r*y.r<10
-
THEN ' '
-
ELSE ''
-
END
-
|| (x.r*y.r),' ') within GROUP (ORDER BY y.r)rr
-
FROM num x,
-
num y
-
WHERE x.r>=y.r
-
GROUP BY x.r;
-
-
WITH num AS
-
( SELECT rownum r FROM dual CONNECT BY level<=9
-
)
-
SELECT lpad(' ',(9-x.r)*7,' ')
-
|| listagg(y.r
-
||'*'
-
||x.r
-
||'='
-
||
-
CASE
-
WHEN x.r*y.r<10
-
THEN ' '
-
ELSE ''
-
END
-
|| (x.r*y.r),' ') within GROUP(ORDER BY y.r DESC) rr
-
FROM num x,
-
num y
-
WHERE x.r>=y.r
-
GROUP BY x.r
-
ORDER BY x.r DESC;
-
-
WITH num AS
-
( SELECT rownum r FROM dual CONNECT BY level<=9
-
)
-
SELECT
-
(SELECT lpad(' ',(9-x.r)*7,' ')
-
|| REPLACE(MAX(sys_connect_by_path(x.r
-
||'*'
-
||(x.r+1-rownum)
-
||'='
-
|| (
-
CASE
-
WHEN (x.r+1-rownum)*x.r<10
-
THEN 'z'
-
ELSE ''
-
END)
-
|| ((x.r+1-rownum)*x.r),' ')),'z',' ')r
-
FROM dual
-
CONNECT BY level<=x.r
-
) xx
-
FROM num x
-
ORDER BY x.r DESC;
-
-
WITH num AS
-
( SELECT rownum r FROM dual CONNECT BY level<=9
-
)
-
SELECT
-
(SELECT REPLACE(MAX(sys_connect_by_path(rownum
-
||'*'
-
||x.r
-
||'='
-
||(
-
CASE
-
WHEN rownum*x.r<10
-
THEN 'z'
-
ELSE ''
-
END)
-
|| (rownum*x.r),' ')),'z',' ') r
-
FROM dual
-
CONNECT BY level<=x.r
-
) xx
- FROM num x;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29254281/viewspace-1150050/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Python列印乘法表Python
- 列印99乘法表
- 九九乘法表
- c#列印99乘法表C#
- 列印九九乘法表
- PHP列印9*9的乘法表PHP
- 列印一個九九乘法表
- C語言九九乘法表C語言
- 如何用python輸出99乘法表Python
- js列印九九乘法表(迴圈)JS
- python 99乘法表,佔位基礎複習Python
- 用js實現列印九九乘法表JS
- Python 6種列印99乘法表的方法詳解!Python
- 如何用java寫一個九九乘法表Java
- JAVA基礎--迴圈語句_列印九九乘法表Java
- 用js 中的for迴圈寫一個九九乘法表!JS
- Python使用雙層列表推導式輸出九九乘法表Python
- 用python做個九九乘法表-夠簡單,能學會Python
- Java技巧:用一個迴圈語句輸出九九乘法表!Java
- 【SQL】17 SQL 檢視(Views)、SQL Date 函式、SQL NULL 值、SQLView函式Null
- Shell 程式設計--九九乘法表--等邊三角形--菱形程式設計
- 【SQL】19 SQL函式SQL函式
- SQL注射/SQL Injection漏洞SQL
- SQL------SQL效能分析SQL
- 【SQL】13 SQL 別名、SQL 連線(JOIN)、SQL INNER JOIN 關鍵字、SQL LEFT JOIN 關鍵字、SQL RIGHT JOIN 關鍵字、SQL FULL OUTER JSQL
- 【SQL】9 SQL INSERT INTO 語句SQL
- 【SQL】10 SQL UPDATE 語句SQL
- 【SQL】11 SQL DELETE 語句SQLdelete
- 【SQL】Oracle 19c SQL隔離詳解(SQL Quarantine)SQLOracle
- SQLSQL
- SQL 已死,但 SQL 將永存!SQL
- False SQL Injection and Advanced Blind SQL InjectionFalseSQL
- 【SQL】SQL中if條件的使用SQL
- 【SQL】Oracle SQL處理的流程SQLOracle
- 【SQL】Oracle SQL共享池檢查SQLOracle
- SQL Access Advisor、SQL Tuning Advisor 測試SQL
- SQL語法之SQL 萬用字元SQL字元
- SQL奇遇記:解鎖 SQL 的秘密SQL
- HighgoDB查詢慢SQL和阻塞SQLGoSQL