[Sql Query] Menemukan selisih dan mengroupingkannya. :)

SELECT r.*,
IF(@lastcell=cell_id,@diff:=SECOND(TIMEDIFF(datetime_production, @interv)),0) selisih,
IF(@diff<11, @count, @count:=@count+1),
@lastcell:=cell_id,
@interv:=datetime_production
FROM
(SELECT * FROM not_goods WHERE date_production = CURDATE() AND (MINUTE(datetime_production)>54 OR MINUTE(datetime_production)<11) ORDER BY cell_id, id, counters) AS r
CROSS JOIN
(SELECT @interv := ‘0000-00-00 00:00:00’, @first:= 0, @lastcell:=NULL, @count :=0, @diff:=0) AS vars
ORDER BY cell_id,counters;

Advertisements

install OCI8 di linux mint.

  1. download instant client dan SDK di sini: http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
  2. extract instant client letakan semua file yang ada di folder hasil extract ke /opt/oci8lib. (sebenernya terserah mau diletakkan dimana).
  3. extract sdknya. buka folder hasil extrak. di sana ada folder sdk.
  4. copy file folder sdk(perhatikan, folder sdk, buka folder hasil extract) ke /opt/oci8lib. ini menyesuaikan dengan tahapan point 2. alias di copy ke folder library oci8 kita.
  5. buka terminal.
  6. lalu run command berikut:

    #menambah path
    echo ‘export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/oci8lib’ >> ~/.profile
    source ~/.profile
    #pindah ke tempat librarynya
    cd /opt/oci8lib
    echo /opt/oci8lib >> /etc/ld.so.conf
    ldconfig
    #buat link
    ln -s libclntsh.so.* libclntsh.so
    #install beberapa komponen
    sudo apt-get install php-pear
    sudo apt-get install php5-dev
    sudo apt-get install libaio-dev
    sudo apt-get install php-pear

    #install oci8-nya

    pecl install oci8-2.0.10

    #jika ditanyatanyain untuk nginput path, enter sajalah. 🙂

  7. testing.
    buat file phpinfo().