Skip to content

Instantly share code, notes, and snippets.

@hidayat365
hidayat365 / table.html
Created February 18, 2014 07:43
Membuat HTML Table dengan Header bertingkat
<table>
<tr>
<th rowspan="3">No.</th>
<th rowspan="3">Nomor Induk</th>
<th rowspan="3">Nama Lengkap</th>
<th colspan="12">Aspek Penilaian</th>
<th rowspan="3">NR</th>
</tr>
<tr>
<th colspan="5">Tugas</th>
@hidayat365
hidayat365 / explain-plan.sql
Created February 19, 2014 16:00
EXPLAIN PLAN menjelaskan Query langsung terhadap table dan view adalah sama saja di MySQL
mysql> -------------------------------------
mysql> ini execution plan
mysql> untuk query langsung ke base table
mysql> -------------------------------------
mysql> explain
-> select a.*, b.account_id, b.item_id, b.debet, b.credit
-> from journals a
-> join journal_details b on a.id=b.journal_id
-> where a.id=1 ;
+----+-------------+-------+-------+-----------------------------+---------+---------+-------+------+-------------+
@hidayat365
hidayat365 / installment.sql
Created April 29, 2014 09:57
Query untuk menjumlahkan pembayaran installment
select tahun, bulan, sum(payment) as payment
from (
select year(payment1_dt) tahun, month(payment1_dt) bulan, payment1 payment from tb_dtinstallment
union all
select year(payment2_dt) tahun, month(payment2_dt) bulan, payment2 payment from tb_dtinstallment
union all
select year(payment3_dt) tahun, month(payment3_dt) bulan, payment3 payment from tb_dtinstallment
union all
select year(payment4_dt) tahun, month(payment4_dt) bulan, payment4 payment from tb_dtinstallment
union all
@hidayat365
hidayat365 / crosstab5.sql
Last active August 29, 2015 14:01
Another MySQL Cross Tab or Pivot Table
F:\xampp\mysql\bin>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.5.36 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
@hidayat365
hidayat365 / unionsample.sql
Created May 19, 2014 06:20
UNION ALL sample
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
@hidayat365
hidayat365 / output.txt
Created November 11, 2014 17:22
Contoh Penggunaan LEFT JOIN dan COALESCE
mysql> create table tbl_inti as
-> select '001' nik, 'Aria' nama union all
-> select '002' nik, 'Budi' nama union all
-> select '003' nik, 'Cici' nama union all
-> select '004' nik, 'Dina' nama union all
-> select '005' nik, 'Elia' nama union all
-> select '006' nik, 'Fandi' nama union all
-> select '007' nik, 'Gina' nama union all
-> select '008' nik, 'Hari' nama union all
-> select '009' nik, 'Icha' nama union all
@hidayat365
hidayat365 / web.config
Created September 11, 2015 08:11
Setting web.config untuk Yii2 basic
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<connectionStrings>
<add connectionString="server=ap-cdbr-azure-southeast-a.cloudapp.net;User Id=user;database=proxima3;password=pass" name="proxima3" providerName="MySql.Data.MySqlClient" />
</connectionStrings>
<system.webServer>
<rewrite>
<rules>
<rule name="Yii2 WebApp Redirect" stopProcessing="true">
<match url="^$" />
@hidayat365
hidayat365 / diskon.php
Created March 12, 2012 03:26
Perhitungan Diskon
<?php
function hitung_total(&$data)
{
// hitung harga
$data['harga_total'] = $data['quantity'] * $data['harga_satuan'];
$data['nilai_diskon'] = $data['harga_total'] * $data['diskon'];
$data['harga_diskon'] = $data['harga_total'] - $data['nilai_diskon'];
// return status
// kita bisa kasih logic
@hidayat365
hidayat365 / FizzBuzz.sql
Created March 15, 2012 06:21
Fizz Buzz Solution using MySQL
select
-- logic untuk fizzbuzz
case
when baris %15 = 0 then 'FizzBuzz'
when baris %3 = 0 then 'Fizz'
when baris %5 = 0 then 'Buzz'
else baris end fizzbuzz
from (
-- generate 100 baris row dan beri nomor
select @no := @no+1 baris
@hidayat365
hidayat365 / layout.html
Created March 19, 2012 12:21
HTML Float Layout
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Contoh Layout</title>
<style>
p { margin: 0; }
.span-3, .span-6, .span-10, .span-23 {
float:left;
margin-right:10px;