Created
May 19, 2014 06:20
-
-
Save hidayat365/4a432eda27da263d0441 to your computer and use it in GitHub Desktop.
UNION ALL sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mysql> use test; | |
| Database changed | |
| mysql> drop view if exists qry_labarugi ; | |
| Query OK, 0 rows affected, 1 warning (0.00 sec) | |
| mysql> create view qry_labarugi as | |
| -> SELECT year(tanggal) AS tahun | |
| -> , month(tanggal) AS bulan | |
| -> , SUM(total_jual) AS total | |
| -> FROM tbl_penjualan | |
| -> GROUP BY year(tanggal) | |
| -> , month(tanggal) | |
| -> | |
| -> UNION ALL | |
| -> SELECT year(tanggal) AS tahun | |
| -> , month(tanggal) AS bulan | |
| -> , SUM(total_beli) AS total | |
| -> FROM tbl_pembelian | |
| -> GROUP BY year(tanggal) | |
| -> , month(tanggal) | |
| -> | |
| -> UNION ALL | |
| -> SELECT year(tanggal) AS tahun | |
| -> , month(tanggal) AS bulan | |
| -> , SUM(jumlah) AS total | |
| -> FROM tbl_pengeluaran | |
| -> GROUP BY year(tanggal) | |
| -> , month(tanggal) | |
| -> | |
| -> ; | |
| Query OK, 0 rows affected (0.04 sec) | |
| mysql> select * from qry_labarugi; | |
| Empty set (0.00 sec) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment