顯示具有 Oracle SQL 標籤的文章。 顯示所有文章
顯示具有 Oracle SQL 標籤的文章。 顯示所有文章

2020年6月6日 星期六

ORDER BY NULLS FIRST、ORDER BY NULLS LAST

原來Oracle有這種語法,SQL Server沒有這語法
https://www.oracletutorial.com/oracle-basics/oracle-order-by/

而且是ANSI SQL:2003語法
https://en.wikipedia.org/wiki/Order_by

2019年1月2日 星期三

不同資料庫SQL Script語法轉換器

線上版
http://www.sqlines.com/online

軟體版(免安裝)
http://www.sqlines.com/download
SQLines SQL Converter is an open source tool (Apache License 2.0) that helps you convert database schema (DDL), queries and DML statements, views, stored procedures, packages, functions and triggers.

原始碼
https://github.com/dmtolpeko/sqlines

2016年4月25日 星期一

2016年4月17日 星期日

2016年4月16日 星期六

各種資料庫Select first rows的方式

SQL - Select first 10 rows only? - Stack Overflow
http://stackoverflow.com/questions/1891789/sql-select-first-10-rows-only

各種資料庫List All Tables

How to List All Tables and Describe Tables in Oracle, MySQL, DB2 and PostgreSQL
http://onewebsql.com/blog/list-all-tables

2016年4月10日 星期日

使用PIVOT函數建立各月份銷售統計報表




2014-08故意沒把NULL改成0
2014-09使用ISNULL函數,其他月份使用COALESCE函數
COALESCE函數是ANSI SQL-92標準,ISNULL函數不是標準
另外SQL Server 2005之後才支援PIVOT函數
Oracle 11g之後也支援函數
MySQL沒有PIVOT函數,要使用GROUP_CONCAT

ref:
比較 ISNULL() 函數以及 COALESCE() 函數
SQL server : Replacing NULL with 0 in a query - Stack Overflow
Databases that support PIVOT/UNPIVOT syntax:

下載Adventure Works 2014 Sample Databases:
https://msftdbprodsamples.codeplex.com/releases/view/125550