-=-
.
.....
  
 
RSS
Direkomendasikan menggunakan brower Opera/Chrome/Firefox. Resolusi minimal 1024x768 | Powered by ____ |
 
  
 
Nikmati Delphi-ID dalam berbagai versi tampilan :
Basic View (LOW Bandwidth)
Default View (Full)
Mobile Edition
Main Menu
..:: onWebTools ::..
..:: onLastPosts ::..
goto Postjumlah komponen maksimal dalam sebuah project(6)
 by d4mnf1y32
 on 21.May at 12:16
goto Posttanya grayscale to biner dengan scanline(1)
 by luckynvic
 on 20.May at 20:44
goto Posttanya looping biner to matriks(1)
 by luckynvic
 on 20.May at 20:10
goto Postsql error:acces denied for user....(2)
 by nasbms
 on 19.May at 16:54
goto Postpemanggilan frame(4)
 by nasbms
 on 19.May at 16:14
goto Posttanya AvLock(0)
 by azuriza
 on 19.May at 11:24
goto PostGet TDBEdit Value Menggunakan LookUp Grid(10)
 by henry_sys
 on 18.May at 11:27
goto Postmenghitung record dalam perulangan(4)
 by idhiel
 on 16.May at 13:53
goto Posttanya ascii(4)
 by mas_kofa
 on 16.May at 12:11
goto PostRawPrint Untuk Delphi XE2(0)
 by adewijaya
 on 15.May at 22:34
goto Postdatabase error..(4)
 by idhiel
 on 15.May at 15:57
goto Postbekasi, pt arila putra mahkota(3)
 by mas_kofa
 on 15.May at 15:37
goto Postbagaimana cara membaca file *.doc dg delphi?(0)
 by ficky
 on 15.May at 06:14
goto Posttanya biner to matriks(13)
 by diandewi
 on 14.May at 20:30

..:: onLast Articles ::..
..:: New Download ::..
Pascal-id.Org
Feeds -  Popular -  Latest
RE: The Longue
8 months, 3 weeks ago
RE: belajar pascal
8 months, 3 weeks ago
RE: The Longue
8 months, 3 weeks ago
RE: belajar pascal
8 months, 3 weeks ago
RE: Perkenalan dan Absen
8 months, 3 weeks ago
RE: Alhamdulillah Buka Puasa Bersama
8 months, 4 weeks ago
RE: تَقَبَّلَ اللهُ مِنَّا وَمِنْكَ - Selamat Hari Raya Idul Fitri
8 months, 4 weeks ago
Lintas Situs
«
free web site stats and visitor tracking

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
b_squaredOffline
Location:
Post subject: Query untuk memilih max(date) dari satu tabel  PostPosted: 01/Jul/2010 17:48
onNovice


Joined: 28-Jun-2010
Posts: 11

Status: Offline
Saya punya tabel pada firebird 2.1 sbb:
idrecord ; iduser ; tgl_login
====================
1 ; 1 ; 1/1/2009
2 ; 1 ; 2/3/2010
3 ; 2 ; 4/5/2009
4 ; 3 ; 6/7/2009
5 ; 2 ; 8/9/2010
6 ; 3 ; 9/9/2010

bagaimana querynya untuk menghasilkan rekord dari tgl terakhir setiap user login. Hasil dari query yg saya inginkan adalah sbb:
idrecord ; iduser ; tgl_login
====================
2 ; 1 ; 2/3/2010
5 ; 2 ; 8/9/2010
6 ; 3 ; 9/9/2010

saya sudah coba dengan query berikut, tapi tidak berhasil:
code : sql
  1. SELECT idrecord, iduser, max(tgl_login)
  2. FROM mytable
  3. GROUP BY iduser
Parsed in 0.001 seconds, using GeSHi
 
 View user's profile Send private message  
Reply with quote Back to top
DelphiExpert
Location:
Post subject:   PostPosted: 01/Jul/2010 18:42
onMage


Joined: 06-Feb-2006
Posts: 2401

Saya kurang ahli dlm SQL Query tapi bisa coba tambahkan: ORDER BY tgl_login DESC atau by idrecord

_________________
Dude, if you don't understand the basics and just want to get someone else write the code for you, it means you really shouldn't study computer science. Find a different field.
http://delphiexpert.wordpress.com
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
b_squaredOffline
Location:
Post subject:   PostPosted: 01/Jul/2010 18:59
onNovice


Joined: 28-Jun-2010
Posts: 11

Status: Offline
@DE: seperti di forum sebelah gan, Smile Smile
query diatas sudah saya coba, hasilnya seperti diatas:
Dynamic SQL Error
SQL error code = -104
 
 View user's profile Send private message  
Reply with quote Back to top
dadanarifinOffline
Location:
Post subject:   PostPosted: 01/Jul/2010 19:49
onSkilled


Joined: 01-Jul-2010
Posts: 67

Status: Offline
coba yang ini
code : sql
  1. SELECT first 1 idrecord, iduser, tgl_login
  2. FROM mytable
  3. ORDER BY tgl_login DESC;
Parsed in 0.001 seconds, using GeSHi


intinya sih klo buat aplikasi user online.. gk pake group by..
mungkin yang anda maksud... user online telah login dan dihitung berapa lama dia login..
mungkin bisa menggunakan group by.. dan tentunya masa waktu dia login dapat kita hidung..

mohon maaf jika mungkin saya salah mengartikan soal yang anda berikan....

_________________
Mohon di tegur kalo saya melanggar peraturan yang berlaku di situs ini.... Dan Mohon Maaf Juga,, Karena tidak ada unsur kesengajaan...
My Web
Facebook
 
 View user's profile Send private message  
Reply with quote Back to top
delphi_warriorOffline
Location:
Post subject:   PostPosted: 02/Jul/2010 08:06
onSkilled


Joined: 14-Feb-2007
Posts: 94

Status: Offline
      b_squared wrote:
@DE: seperti di forum sebelah gan, Smile Smile
query diatas sudah saya coba, hasilnya seperti diatas:
Dynamic SQL Error
SQL error code = -104


mungkin sy bisa bantu

select idrecord, iduser, max(tgl_login)
from mytable
group by iduser, idrecord

kalo pake group by field yg tdk dipakai dgn fungsi max, min, count, sum
hrs disertakan di group by nya....

dlm hal ini idrecordnya harus disertakan

moga membantu
 
 View user's profile Send private message  
Reply with quote Back to top
mas_kofa
Location: New York Arto
Post subject:   PostPosted: 02/Jul/2010 09:09
onElite


Joined: 18-Mar-2006
Posts: 1753
Location: New York Arto
kalo seinget aku untuk struktur query di Interbase (mirip firebird)..... fungsi agrerat (max, sum, count, dll) harus ditaruh di field pertama



select max(tgl_login), idrecord, iduser, from mytable
group by iduser, idrecord


sorry jika salah

_________________
Pay Per Day | Pesbuk
Me isn't mine
Aku Ini adalah satu

Cerdik seperti ular, Tulus seperti merpati
 
 View user's profile Send private message  
Reply with quote Back to top
b_squaredOffline
Location:
Post subject:   PostPosted: 05/Jul/2010 10:49
onNovice


Joined: 28-Jun-2010
Posts: 11

Status: Offline
Link do forum sebelah:
http://delphi-id.tk/query-untuk-memilih ... ml#pid1733
Saya coba dengan query berikut, sepertinya sesuai dengan yg saya harapkan (sharing, sekalian kalo ada query tg lebih baik, mohon masukannya)
code : sql
  1. SELECT a.idrecord, a.iduser, a.TMT_SK
  2. FROM mytable a JOIN
  3. (SELECT b.iduser, max(b.tgl_login) FROM mytable b GROUP BY b.iduser) tb(IDPEGAWAI , maxtgl_login)
  4. ON a.iduser=tb.iduser AND a.TMT_SK=tb.maxtgl_login
Parsed in 0.002 seconds, using GeSHi
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 12 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic





Powered by PNphpBB2 © 2003-2009 The Zafenio Team
Credits


| Register | Lost Password ? |