473,770 Members | 2,144 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Last vs Max

I have a sales table that logs sales information for each active job at the
end of each month. My question is, will the following query give me the last
sell price for each job in the sales table?

SELECT DISTINCTROW tblJobSales.Job , Last(tblJobSale s.SellPrice) AS SellPrice
FROM tblJobSales WHERE (((tblJobSales. SellDate) Between #1/1/2007# And
#12/31/2007#)) GROUP BY tblJobSales.Job ;

I have been using Max(tblJobSales .SellPrice), but I can have jobs where the
sell price goes down from one month to next.
Jobs that were completed in February would not have a record in March.
Mar 19 '07 #1
3 6361
On Mon, 19 Mar 2007 16:21:05 -0500, "paii, Ron" <pa**@packairin c.com>
wrote:

Not necessarily.
The way I understand Last, it depends on the sort order. If (unlikely)
we were sorted by SellDate DESC, this query would retrieve the first
amount. Better be explicit.

Alternatively (and to me more reliably) you'd get the max SellDate per
Job in another query, and then join that with the JobSales table,
joining on both fields, to get some fields such as SellPrice for the
max date per job.

-Tom.

>I have a sales table that logs sales information for each active job at the
end of each month. My question is, will the following query give me the last
sell price for each job in the sales table?

SELECT DISTINCTROW tblJobSales.Job , Last(tblJobSale s.SellPrice) AS SellPrice
FROM tblJobSales WHERE (((tblJobSales. SellDate) Between #1/1/2007# And
#12/31/2007#)) GROUP BY tblJobSales.Job ;

I have been using Max(tblJobSales .SellPrice), but I can have jobs where the
sell price goes down from one month to next.
Jobs that were completed in February would not have a record in March.
Mar 20 '07 #2
Thanks for your response Tom.

I was thinking I would need a 2nd query sorted by date, but was hoping the
WHERE clause would have the same affect. This query actually worked on my
current data, but I was concerned that it would fail when more records were
added.

"Tom van Stiphout" <no************ *@cox.netwrote in message
news:g4******** *************** *********@4ax.c om...
On Mon, 19 Mar 2007 16:21:05 -0500, "paii, Ron" <pa**@packairin c.com>
wrote:

Not necessarily.
The way I understand Last, it depends on the sort order. If (unlikely)
we were sorted by SellDate DESC, this query would retrieve the first
amount. Better be explicit.

Alternatively (and to me more reliably) you'd get the max SellDate per
Job in another query, and then join that with the JobSales table,
joining on both fields, to get some fields such as SellPrice for the
max date per job.

-Tom.

I have a sales table that logs sales information for each active job at
the
end of each month. My question is, will the following query give me the
last
sell price for each job in the sales table?

SELECT DISTINCTROW tblJobSales.Job , Last(tblJobSale s.SellPrice) AS
SellPrice
FROM tblJobSales WHERE (((tblJobSales. SellDate) Between #1/1/2007# And
#12/31/2007#)) GROUP BY tblJobSales.Job ;

I have been using Max(tblJobSales .SellPrice), but I can have jobs where
the
sell price goes down from one month to next.
Jobs that were completed in February would not have a record in March.

Mar 20 '07 #3
Why would the following query not give me the max date for each job?

SELECT DISTINCTROW tblJobSales.Job , Last(tblJobSale s.SellDate) AS
LastOfSellDate
FROM tblJobSales
GROUP BY tblJobSales.Job
ORDER BY tblJobSales.Job , Last(tblJobSale s.SellDate);

This one works.

SELECT DISTINCTROW tblJobSales.Job , Max(tblJobSales .SellDate) AS
MaxOfSellDate
FROM tblJobSales
GROUP BY tblJobSales.Job
ORDER BY tblJobSales.Job ;

"paii, Ron" <pa**@packairin c.comwrote in message
news:hu******** *************** *******@athenet .net...
Thanks for your response Tom.

I was thinking I would need a 2nd query sorted by date, but was hoping the
WHERE clause would have the same affect. This query actually worked on my
current data, but I was concerned that it would fail when more records
were
added.

"Tom van Stiphout" <no************ *@cox.netwrote in message
news:g4******** *************** *********@4ax.c om...
On Mon, 19 Mar 2007 16:21:05 -0500, "paii, Ron" <pa**@packairin c.com>
wrote:

Not necessarily.
The way I understand Last, it depends on the sort order. If (unlikely)
we were sorted by SellDate DESC, this query would retrieve the first
amount. Better be explicit.

Alternatively (and to me more reliably) you'd get the max SellDate per
Job in another query, and then join that with the JobSales table,
joining on both fields, to get some fields such as SellPrice for the
max date per job.

-Tom.

>I have a sales table that logs sales information for each active job at
the
>end of each month. My question is, will the following query give me the
last
>sell price for each job in the sales table?
>
>SELECT DISTINCTROW tblJobSales.Job , Last(tblJobSale s.SellPrice) AS
SellPrice
>FROM tblJobSales WHERE (((tblJobSales. SellDate) Between #1/1/2007# And
>#12/31/2007#)) GROUP BY tblJobSales.Job ;
>
>I have been using Max(tblJobSales .SellPrice), but I can have jobs where
the
>sell price goes down from one month to next.
>Jobs that were completed in February would not have a record in March.
>


Mar 20 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
3620
by: SimonC | last post by:
I would like to return data from the last 2 weeks of each given month in Javascript, but in 2 formats. So, the penultimate week (Monday to Sunday) and the last week (Monday to ??) I'm not sure if it can be done, but all help welcomed. E.g. I have December and would like to see the last 2 weeks.. So this doesnt mean the last 15 days. What i mean by this is...
7
2155
by: Scott W Gifford | last post by:
Hello, I'm considering using XML to represent a stream of location information, and XPath to do queries against it. I've got most of it figured out (at least on paper), but I can't figure out how to create an XPath statement asking for the "last node with a value less than" a given value. I need this to be able to ask "Where was Scott at 11:00 yesterday", which should find the last sighting of Scott before or at 11:00
3
2021
by: AndyBell | last post by:
Hi all! I have an Access 2000 database for the Habiat for Humanity where I work. This is the second database I have written and it gets a bit more complex each time... I have learned much and read much over the last few months and have found leads to the answers to several other problems I have encountered with a Google search of past posts/threads. SO thank you for the help already rendered even though you didn't know!! My problem...
32
4154
by: James Curran | last post by:
I'd like to make the following proposal for a new feature for the C# language. I have no connection with the C# team at Microsoft. I'm posting it here to gather input to refine it, in an "open Source" manner, and in an attempt to build a ground-swell of support to convince the folks at Microsoft to add it. Proposal: "first:" "last:" sections in a "foreach" block The problem: The foreach statement allows iterating over all the...
2
2946
by: rf | last post by:
Hey I need to be able to get the dates from last wednesday to the past tuesday on thursday or friday every week. How would I do that? For example: m t W TH F M T w th f I would need the dates of the CAPITAL W and T when I run the script from the last th or f
17
2529
by: michel.ank | last post by:
Hi, I'm using the class PrintLines and my last record of page aren't with the borders. Somebody can help me? Thanks,
6
5787
by: magix | last post by:
Hi, when I read entries in file i.e text file, how can I determine the first line and the last line ? I know the first line of entry can be filtered using counter, but how about the last line of entry in EOF while loop ? while (! file.eof() ) { ....
2
3269
by: Kevin Burton | last post by:
I don't think I understand the last() function. I have a document that looks like: <Root> <Header>Some text</Header> <Message> <MessageID>1</MessageID> . . . . </Message>
13
14943
by: Greg | last post by:
Most suggestions on this topic recommend to use a page footer and make it visible only on the last page. My problem is that the footer is half of the height of a page which means the detail would show on only the top half of each page with whitepace at the bottom of each page. How can I get the detail to fill each page with my "half page height" report footer at the bottom of the last page? Any suggestions to solve this would be...
23
18085
by: Florian Lindner | last post by:
Hello, can I determine somehow if the iteration on a list of values is the last iteration? Example: for i in : if last_iteration: print i*i else:
0
9618
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.