Sign Up |  Live StatsLive Stats    Articles 34,880| Comments 154,874| Members 17,230, Newest IronSingh25| Online 286
Home Contact
 (Forgotten?): 
    Sikhism

   
                                                                     Your Banner Here!    

 
 
  
  
Sikh Philosophy Network » Members Lounge » Information Technology » query help - retrieve only those with highest value

query help - retrieve only those with highest value

Our Donation Goal : Why Donate? : Donate Today! : Donate Anonymously (ਗੁਪਤ) : Our Family of Supporters
Goal this month: 400 USD, Received: 25 USD (6%)
Please Donate...
Related Topics...
Thread Thread Starter Forum Replies Last Post
Strategies for the Highest Good Soul_jyot Spiritual Articles 1 10-Feb-2007 00:55 AM
help! query for unique and highest value I need help! Information Technology 1 28-Jul-2006 08:20 AM
How do I retrieve a missing calander? MIA Information Technology 2 28-Jul-2006 08:14 AM
Getting highest level output MJc215 Information Technology 1 18-Nov-2005 14:00 PM
Retrieve First and Last record from a query used on one form Kou Vang Information Technology 1 01-Nov-2005 13:40 PM


Tags
query, help, retrieve, those, highest, value
Reply Post New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!
  #1 (permalink)  
Old 28-Jul-2006, 08:07 AM
access user's Avatar access user
Guest
 
Posts: n/a
   
   
query help - retrieve only those with highest value

  Donate Today!   Email to Friend  Tell a Friend   Show Printable Version  Print   Contact sikhphilosophy.net Administraion for any Suggestions, Ideas, Feedback.  Feedback  

Register to Remove Advertisements
I have a query and I wish to restrict the returned values to only those
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/information-technology/9869-query-retrieve-only-those-highest-value.html
where, for a particular field, the value is the highest.

For example, a property can have had a number of rent agreements but, in the
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9869
following example, I don't want ALL the records, just the one where VarNo is
the highest

PropertyNo TenantNo VarNo
1 1 1
1 1 2
1 2 3

I *only* want the last line not all three lines.

TIA
James



 
Do share your immediate thoughts or reactions on this issue? We value your views! Login Now! or Sign Up Today! to share your views with us.. Gurfateh!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 28-Jul-2006, 08:07 AM
access user's Avatar access user
Guest
 
Posts: n/a
   
   
RE: query help - retrieve only those with highest value

Also, just to clarify this is an *additional* constraint to one I already
have in the query. That is, I want only those results where *both* conditions
are met.
Firstly, where ContractEndDate>=Date()
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9869
Secondly, where (having met the above condition), VarNo is the highest

TIA

"access user" wrote:

> I have a query and I wish to restrict the returned values to only those
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9869
> where, for a particular field, the value is the highest.
>
> For example, a property can have had a number of rent agreements but, in the
> following example, I don't want ALL the records, just the one where VarNo is
> the highest
>
> PropertyNo TenantNo VarNo
> 1 1 1
> 1 1 2
> 1 2 3
>
> I *only* want the last line not all three lines.
>
> TIA
> James

Reply With Quote
  #3 (permalink)  
Old 28-Jul-2006, 08:08 AM
MNewsGroup's Avatar MNewsGroup
Guest
 
Posts: n/a
   
   
Re: query help - retrieve only those with highest value

123456
"access user" wrote in message
news:FBCDD485-AAFA-4E68-9E52-11919E664093@microsoft.com...
> Also, just to clarify this is an *additional* constraint to one I already
> have in the query. That is, I want only those results where *both*
> conditions
> are met.
> Firstly, where ContractEndDate>=Date()
> Secondly, where (having met the above condition), VarNo is the highest
>
> TIA
>
> "access user" wrote:
>
>> I have a query and I wish to restrict the returned values to only those
>> where, for a particular field, the value is the highest.
>>
>> For example, a property can have had a number of rent agreements but, in
>> the
>> following example, I don't want ALL the records, just the one where VarNo
>> is
>> the highest
>>
>> PropertyNo TenantNo VarNo
>> 1 1 1
>> 1 1 2
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9869
>> 1 2 3
>>
>> I *only* want the last line not all three lines.
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9869
>>
>> TIA
>> James


Reply With Quote
  #4 (permalink)  
Old 28-Jul-2006, 08:08 AM
Michael H's Avatar Michael H
Guest
 
Posts: n/a
   
   
RE: query help - retrieve only those with highest value

Hi.

Assuming the name of your table is "TableName", try this:

SELECT TableName.PropertyNo, TableName.TenantNo, TableName.VarNo
FROM TableName
WHERE (TableName.VarNo)=(SELECT Max(VarNo) AS MaxVarNo FROM TableName WHERE
(TableName.ContractEndDate)>=Date());

-Michael


"access user" wrote:

> Also, just to clarify this is an *additional* constraint to one I already
> have in the query. That is, I want only those results where *both* conditions
> are met.
> Firstly, where ContractEndDate>=Date()
> Secondly, where (having met the above condition), VarNo is the highest
>
> TIA
>
> "access user" wrote:
>
> > I have a query and I wish to restrict the returned values to only those
> > where, for a particular field, the value is the highest.
> >
> > For example, a property can have had a number of rent agreements but, in the
> > following example, I don't want ALL the records, just the one where VarNo is
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9869
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9869
> > the highest
> >
> > PropertyNo TenantNo VarNo
> > 1 1 1
> > 1 1 2
> > 1 2 3
> >
> > I *only* want the last line not all three lines.
> >
> > TIA
> > James

Reply With Quote
  #5 (permalink)  
Old 28-Jul-2006, 08:08 AM
Gina's Avatar Gina
Guest
 
Posts: n/a
   
   
RE: query help - retrieve only those with highest value

In your query you could try putting VarNo field in Descending order and then
right click - properties and where it says 'All' type in '1'. This will
return the top value (one record) in the VarNo field.
--
Gina


"access user" wrote:

> I have a query and I wish to restrict the returned values to only those
> where, for a particular field, the value is the highest.
>
> For example, a property can have had a number of rent agreements but, in the
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9869
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9869
> following example, I don't want ALL the records, just the one where VarNo is
> the highest
>
> PropertyNo TenantNo VarNo
> 1 1 1
> 1 1 2
> 1 2 3
>
> I *only* want the last line not all three lines.
>
> TIA
> James

Reply With Quote
  #6 (permalink)  
Old 28-Jul-2006, 08:08 AM
access user's Avatar access user
Guest
 
Posts: n/a
   
   
RE: query help - retrieve only those with highest value

Thanks - not sure where to put the 1. Bringing up field properties does not
give me any such option.
James

"Gina" wrote:

> In your query you could try putting VarNo field in Descending order and then
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9869
> right click - properties and where it says 'All' type in '1'. This will
> return the top value (one record) in the VarNo field.
> --
> Gina
>
>
> "access user" wrote:
>
> > I have a query and I wish to restrict the returned values to only those
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9869
> > where, for a particular field, the value is the highest.
> >
> > For example, a property can have had a number of rent agreements but, in the
> > following example, I don't want ALL the records, just the one where VarNo is
> > the highest
> >
> > PropertyNo TenantNo VarNo
> > 1 1 1
> > 1 1 2
> > 1 2 3
> >
> > I *only* want the last line not all three lines.
> >
> > TIA
> > James

Reply With Quote
  #7 (permalink)  
Old 28-Jul-2006, 08:08 AM
access user's Avatar access user
Guest
 
Posts: n/a
   
   
RE: query help - retrieve only those with highest value

Thanks - I get a syntax error on the following bit:

=(SELECT Max(VarNo) AS MaxVarNo FROM TableName WHERE

missing ) , ] etc...

James


Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9869
"Michael H" wrote:

> Hi.
>
> Assuming the name of your table is "TableName", try this:
>
> SELECT TableName.PropertyNo, TableName.TenantNo, TableName.VarNo
> FROM TableName
> WHERE (TableName.VarNo)=(SELECT Max(VarNo) AS MaxVarNo FROM TableName WHERE
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9869
> (TableName.ContractEndDate)>=Date());
>
> -Michael
>
>
> "access user" wrote:
>
> > Also, just to clarify this is an *additional* constraint to one I already
> > have in the query. That is, I want only those results where *both* conditions
> > are met.
> > Firstly, where ContractEndDate>=Date()
> > Secondly, where (having met the above condition), VarNo is the highest
> >
> > TIA
> >
> > "access user" wrote:
> >
> > > I have a query and I wish to restrict the returned values to only those
> > > where, for a particular field, the value is the highest.
> > >
> > > For example, a property can have had a number of rent agreements but, in the
> > > following example, I don't want ALL the records, just the one where VarNo is
> > > the highest
> > >
> > > PropertyNo TenantNo VarNo
> > > 1 1 1
> > > 1 1 2
> > > 1 2 3
> > >
> > > I *only* want the last line not all three lines.
> > >
> > > TIA
> > > James

Reply With Quote
  #8 (permalink)  
Old 28-Jul-2006, 08:08 AM
Michael H's Avatar Michael H
Guest
 
Posts: n/a
   
   
RE: query help - retrieve only those with highest value

  Donate Today!  
Did you paste the entire bit of SQL I posted? If your SQL ends at the word
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9869
"WHERE", then you did not. Please ensure thay you copy and paste everything
from the first SELECT statement to the semicolon at the end. I have tested
it and it works just as you had specified it should.
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9869

If you have done the above and are still having problems, please post the
exact SQL you are using, as something may have gotten changed in the
transition.

-Michael


"access user" wrote:

> Thanks - I get a syntax error on the following bit:
>
> =(SELECT Max(VarNo) AS MaxVarNo FROM TableName WHERE
>
> missing ) , ] etc...
>
> James
>
>
> "Michael H" wrote:
>
> > Hi.
> >
> > Assuming the name of your table is "TableName", try this:
> >
> > SELECT TableName.PropertyNo, TableName.TenantNo, TableName.VarNo
> > FROM TableName
> > WHERE (TableName.VarNo)=(SELECT Max(VarNo) AS MaxVarNo FROM TableName WHERE
> > (TableName.ContractEndDate)>=Date());
> >
> > -Michael
> >
> >
> > "access user" wrote:
> >
> > > Also, just to clarify this is an *additional* constraint to one I already
> > > have in the query. That is, I want only those results where *both* conditions
> > > are met.
> > > Firstly, where ContractEndDate>=Date()
> > > Secondly, where (having met the above condition), VarNo is the highest
> > >
> > > TIA
> > >
> > > "access user" wrote:
> > >
> > > > I have a query and I wish to restrict the returned values to only those
> > > > where, for a particular field, the value is the highest.
> > > >
> > > > For example, a property can have had a number of rent agreements but, in the
> > > > following example, I don't want ALL the records, just the one where VarNo is
> > > > the highest
> > > >
> > > > PropertyNo TenantNo VarNo
> > > > 1 1 1
> > > > 1 1 2
> > > > 1 2 3
> > > >
> > > > I *only* want the last line not all three lines.
> > > >
> > > > TIA
> > > > James

Reply With Quote
   Click Here to Donate Now!

Support Us!
Become a Promoter!
Gurfateh ji, you can become a SPN Promoter by Donating as little as $10 each month. With limited resources & high operational costs, your donations make it possible for us to deliver a quality website and spread the teachings of the Sri Guru Granth Sahib Ji, to serve & uplift humanity. Every contribution counts. Donate Generously. Gurfateh!
ReplyPost New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!

Bookmarks


(View-All Members who have read this thread : 0
There are no names to display.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Tools Search
Search:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

» Gurbani Jukebox
Listen to Gurbani while surfing SPN!
» Recent Discussions
sikhism Undercover Mosque
Today 13:14 PM
1 Replies, 55 Views
sikhism Eighteen Super-Natural...
Today 13:11 PM
31 Replies, 3,450 Views
sikhism Mysticism In Religion:...
Today 12:57 PM
3 Replies, 1,001 Views
sikhism What Prayer Does to Your...
Today 12:21 PM
3 Replies, 281 Views
sikhism Four Steps To God
Today 12:11 PM
2 Replies, 236 Views
sikhism Benti Chaupai - Keertan...
Today 11:53 AM
17 Replies, 276 Views
sikhism Fools Who Wrangle Over...
Today 11:46 AM
917 Replies, 77,938 Views
sikhism Incidental Happiness...
Today 10:24 AM
1 Replies, 78 Views
sikhism Meditate - How, What,...
Today 08:30 AM
41 Replies, 1,193 Views
sikhism Are Nihangs: A Legacy...
Today 08:12 AM
15 Replies, 269 Views
sikhism Sukhmani Sahib Astpadi 8...
Today 06:38 AM
0 Replies, 27 Views
sikhism Is Hindu/Sikh a Valid...
Today 02:20 AM
82 Replies, 1,482 Views
sikhism Amazing truth!
Yesterday 22:20 PM
0 Replies, 73 Views
sikhism Black money: Indians...
Yesterday 21:40 PM
1 Replies, 61 Views
sikhism Sikh temple brawl a...
Yesterday 20:33 PM
0 Replies, 69 Views
» Books You Should Read...
Powered by vBadvanced CMPS v3.2.2

All times are GMT +6.5. The time now is 13:16 PM.
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.5.2 Copyright © 2004-12, All Rights Reserved. Sikh Philosophy Network


Page generated in 0.47267 seconds with 30 queries