Skip to content

Instantly share code, notes, and snippets.

@hidayat365
hidayat365 / crosstab3.sql
Last active October 11, 2021 06:56
MySQL Crosstab Example, Mengubah Row Menjadi Kolom hanya dengan satu perintah SQL saja via @berthojoris
mysql> use test;
Database changed
mysql> ---------------------------------
mysql> -- buat table dan sample datanya
mysql> ---------------------------------
mysql> create table tbl_data as
-> select '1' ID ,'001' NOPEL, 'INQUIRY' KATEGORI union all
-> select '2' ID ,'002' NOPEL, 'COMPLAINT' KATEGORI union all
-> select '3' ID ,'003' NOPEL, 'REQUEST' KATEGORI union all
@hidayat365
hidayat365 / before-insert.sql
Created July 22, 2013 02:47
Penomoran Faktur Otomatis Menggunakan Trigger Before Insert di MySQL
mysql> use test
Database changed
mysql> ----------------------------------------
mysql> -- create table penjualan
mysql> ----------------------------------------
mysql> create table penjualan (
-> id int auto_increment primary key,
-> no_faktur varchar(50) not null
-> )
@hidayat365
hidayat365 / crviewer.cs
Last active December 20, 2015 01:49
Menampilkan Report Crystal Report
public void ShowProfitLossReport(int month, int year)
{
InitializeConnectionInfo();
rpt = new Finance.rptProfitLoss();
rpt.ParameterFields["bulan"].CurrentValues.AddValue(month);
rpt.ParameterFields["tahun"].CurrentValues.AddValue(year);
rpt.ParameterFields["span"].CurrentValues.AddValue("MONTHLY");
SetReportLogonInfo(rpt);
crViewer1.ReportSource = rpt;
crViewer1.Zoom(1);
@hidayat365
hidayat365 / hasil.sql
Created July 22, 2013 08:18
penasaran.com - query bodoh2an untuk mengganti string tertentu di mysql
mysql> create table anu_table (
-> id int auto_increment primary key,
-> ukuran varchar(50) null
-> ) ;
Query OK, 0 rows affected (0.01 sec)
mysql> insert into anu_table (ukuran)
-> values ('200mm2'), ('250mm2'), ('20 x 50 mm2'), ('1 x 2 mm'), ('1 x 5mm2'), ('1 m2') ;
Query OK, 6 rows affected (0.00 sec)
Records: 6 Duplicates: 0 Warnings: 0
@hidayat365
hidayat365 / caseclause.sql
Last active December 20, 2015 12:09
Contoh SQL untuk perhitungan menggunakan CASE clause
mysql> ----------------------------
mysql> -- set database
mysql> ----------------------------
mysql> use test;
Database changed
mysql> ----------------------------
mysql> -- create table
mysql> ----------------------------
mysql> create table penggunaan (
@hidayat365
hidayat365 / theming-tables.php
Last active December 21, 2015 09:19
Theming Form with Tables di Drupal7
<?php
/*
* form_theming_tableform
* definisi form berbentuk table
**/
function form_theming_tableform()
{
$form['people'] = array(
'#prefix' => '<div id="people">',
@hidayat365
hidayat365 / CEmployee.vb
Last active December 22, 2015 19:39
Contoh Class Data Access Helper dengan bantuan CommandBuilder untuk generate INSERT/UPDATE/DELETE secara otomatis, disertai dengan contoh penggunaannya di Form1.vb. Update untuk searching yaitu dengan menambahkan TextBox dan Button untuk searching
Imports System.Data
Imports System.Data.SqlServerCe
''' <summary>
''' Interface IDataAccess
''' </summary>
''' <remarks>Untuk keseragaman metode akses data</remarks>
Public Interface IDataAccess
Function GetData() As DataTable
@hidayat365
hidayat365 / yii-summary.php
Created September 11, 2013 22:55
Yii: Cara penggunaan CSqlDataProvider untuk membuat summary sehingga bisa ditampilkan menggunakan CGridView
/************************************************************
* MODEL *
************************************************************/
<?php
/**
* Summary Propinsi
*/
public function getSummaryPropinsi()
{
@hidayat365
hidayat365 / CDataAccessInherits.vb
Last active December 22, 2015 23:29
Contoh generalisasi statusisasi Class Data Access. Pengembangan dari => Class Data Access Helper dengan bantuan CommandBuilder untuk generate INSERT/UPDATE/DELETE secara otomatis, Contoh penggunaan dalam Form dapat dilihat di sini => https://gist.github.com/hidayat365/6521333
Imports System.Data
Imports System.Data.SqlServerCe
''' <summary>
''' Data Access Layer ke table Employees
''' </summary>
''' <remarks>
''' Data Access Layer ke table Employees,
''' Inherits dari CDataAccess dengan Constructor untuk set table dan query
@hidayat365
hidayat365 / sqlquery.txt
Created October 2, 2013 02:33
Menghitung nilai Minimum, Maksimum, Rata-rata, dan Total menggunakan SQL query
D:\xampp\mysql\bin>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, 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.