Home » SQL & PL/SQL » SQL & PL/SQL » Top 1
Top 1 [message #210354] Wed, 20 December 2006 08:28 Go to next message
fmrock
Messages: 45
Registered: December 2006
Member
Hey All, Just found this forum and going to post my very first newbie question.

I am working with a rather large Oracle database system.

I am tasked with creating reports from this system.

There is a table with the charges that are on accounts. I need to pull out the most recent charge date.

The date is also stored as a Juliandate.

In SQL server I could do a
select top 1 x from tblCharges order by x DESC

Any advice would be great.
Thanks
Re: Top 1 [message #210358 is a reply to message #210354] Wed, 20 December 2006 08:35 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
Search and you will find. On the FAQ pages you will find an article addressing this issue.

MHE
Re: Top 1 [message #210361 is a reply to message #210354] Wed, 20 December 2006 08:37 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
Use max() function.
Functions
By
Vamsi
Re: Top 1 [message #210387 is a reply to message #210354] Wed, 20 December 2006 09:41 Go to previous message
fmrock
Messages: 45
Registered: December 2006
Member
Ok, so here is my next question.

I have a query that pulls back accounts that match certain criteria.

Part of that query checks the tblCharges to see if a Payment exists in the subquery.

Select * From tblAccounts
where x=y
and EXISTS()

Part of the charge record is the payment date. I need that last payment date as part of my query. Any ideas on how to accomplish this?

The account to charges table is one to many.
There could be many payments,charges,adjustments for each account

[Updated on: Wed, 20 December 2006 09:44]

Report message to a moderator

Previous Topic: sql qurey
Next Topic: migrate wrapped package
Goto Forum:
  


Current Time: Mon Dec 05 21:27:50 CST 2016

Total time taken to generate the page: 0.05183 seconds