Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> MIN function help
Can you help me with some SQL (probably really simple)?
I want to bet the first deposit date and amount for each user so wrote this query:
SELECT b.user_id, MIN(date_inserted), b.amount/100 as amount_deposited
FROM rpt_player_cash_summary a, gl_user_transactions b
WHERE a.user_id = b.user_id
AND b.status = 'COMPLETE'
AND b.type = 'DEPOSIT'
GROUP BY b.user_id, b.amount
ORDER BY user_id;
Here's a sample of data returned. If you look at user_id 181156, there are multiple entries. I just want the query to return the row for 21/07/2005.
USER_ID MIN(DATE_INSERTED) AMOUNT_DEPOSITED 181068 20/07/2005 21:10:12 10 181131 21/07/2005 17:22:50 20 181156 21/07/2005 22:20:20 10 181156 28/07/2005 03:15:56 20 181165 21/07/2005 23:49:58 10 181238 23/07/2005 00:41:25 50 181323 24/07/2005 14:11:20 30
Please can you help? Received on Thu Aug 04 2005 - 04:41:26 CDT