Archive for April, 2012


Fetch first row in DB2

Today I face a problem: If I select data using order by transaction_date, the result will be ordered by date (ascending by default) an row count may be more than 1. This is query that I’m use:

SELECT * FROM transaction ORDER BY transaction_date

But, cost (of I/O) of this query is too big.. this query execution will need very long time depend on how many data in table Transaction. I don’t want use this query, but I need the latest data transaction, I need first row only.

In DB2, we can simplify this matter, just modify query above to be like this:

SELECT * FROM transaction ORDER BY transaction_date FETCH FIRST ROW ONLY

Using this new query, cost of I/O will be small, and query execution will be so fast 8-)

TRIM in DB2

Today I want to try how to TRIM in select, using database DB2.
We can use function RTRIM (for TRIM right space) or LTRIM (TRIM left space).

For example.. assume that we have column field1 in table transactions with datatype varchar and have value ‘   hello’:

SELECT LTRIM(field1) FROM transactions

Cobe above will return ‘hello’ respectively. So simple :)

Mau kirim paket ke luar kota atau keluar negeri, tapi bingung gimana caranya?

Kini telah dibuka: PAHALA KENCANA EXPRESS DELIVERY.

Melayani pengiriman Dalam & Luar Negeri. Dijamin aman sampai ke tempat tujuan dan ongkos kirim terjangkau!

Melayani Titipan :

  • Paket / Dokumen
  • Sepeda Motor / Mobil
  • Moving / Pindahan Rumah & Kantor
  • Dan lain-lain

Kunjungi cabang kami di:
PD USAHA JAYA
Jl. Cipagalo Girang No. 33
Telp : (022) 7561125
Bandung – Jawa Barat

Koordinat Google Maps: -6.95367,107.64805

Berikut ini penampakan tokonya :mrgreen:

Toko PD Usaha Jaya

Pertanyaan, kritik, saran & masukan? Silahkan masukan pada komentar di bawah ini. :)

Follow

Get every new post delivered to your Inbox.

Join 1,515 other followers