473,441 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,441 software developers and data experts.

Max(date) problem

Hello,
I am stuck trying to select records from a view. I need max(date) to select the topmost date, but I also need to select records based on date criteria.

Expand|Select|Wrap|Line Numbers
  1. SELECT MAX(rc_date) AS rc_date, SUM(rc_amount) AS rc_amount, rc_method, p_p_acno AS CustomerNumber
  2. FROM View_ReceivingReport
  3. GROUP BY rc_method, p_p_acno, pc_name
  4. HAVING (rc_method = 'CREDITCARD') AND (pc_name <> '') AND (dbo.GetDelimitedFieldRight(pc_name) = 'PST')
  5. ORDER BY pc_name
  6.  
  7. 2010-01-20 6000.00 Showname1 CREDITCARD Customer1 Event1
  8. 2010-01-18 796.00 Showname2 CREDITCARD Customer2 Event2
This gives the max date of all records in the view, but how do I select a date range while keeping single max(rc_date) and grouping?

Thank you
Aug 4 '10 #1
6 1502
ck9663
2,878 Expert 2GB
Where do you need the date range? Could you give some sample data and how you want your result to look like?

~~ CK
Aug 5 '10 #2
I solved it by selecting all records by date into a temp table, then applying the query above. Thanks!
Aug 5 '10 #3
NeoPa
32,556 Expert Mod 16PB
That would be your WHERE clause Susan.

GROUP BY queries can have WHERE, as well as HAVING, clauses. The WHERE clause applies its filtering to the incoming records (IE. Before any grouping) while the HAVING clause applies its filtering to the processed/outgoing records.

Welcome to Bytes!
Aug 5 '10 #4
Thanks, but I obviously had used the Where clause without the result I wanted.
Aug 5 '10 #5
NeoPa
32,556 Expert Mod 16PB
I'm struggling to see obvious Susan. It wasn't included in the post.
Aug 5 '10 #6
I didn't mean to offend, problem is solved.
Aug 5 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jim | last post by:
Say I have a table like this (just for example) ID Date Name __ ____ _____ 1 1/2/2004 Store A 2 1/1/2004 Store A 3 1/3/2004 Store B 4 1/2/2004 Store B
14
by: peteh | last post by:
Hi All; We have many production jobs that "load from cursor" to a UDB/AIX 8.2 (with dpf) data warehouse from source tables residing Oracle 9i. Since Oracle dates are (roughly) equivalent to DB2...
1
by: NBaker | last post by:
I have 1 table 'Data' and i need to select the max date. The table contains multiple rows per URN so I need all the fields where the date is most recent. URN £ Date Gift Type ...
1
by: 400NEWBIE | last post by:
Hi everyone, I'm having trouble figuring out how to select the max date in MS ACCESS from an AS400 table with a composite key. Here's my data: Type Name Select-Rule Error-Rule Effec-Date...
1
by: Freddie | last post by:
Hello everyone: i am trying to compare a MAX(DATE) from one table that would be greater than a date in another. first_table compname MYDATE abc comp 2006-09-26 09:19:43.250
1
by: Matik | last post by:
Hello Everybody, I have a problem, with select stmt: SELECT TOP 15 * FROM oaVIEW_MainData AS TOP_VIEW, oaLanguageData_TAB AS RwQualifierJoin with (nolock) WHERE (c_dateTime>='2007.01.10...
1
by: abetancur | last post by:
I have the following code: SELECT MAX(INVENTORY_TRANSACTION_HIST.DATE_APPLIED) AS LAST_TRANS, INVENTORY_TRANSACTION_HIST.PART_NO FROM INVENTORY_TRANSACTION_HIST INNER JOIN ...
3
Inbaraj
by: Inbaraj | last post by:
Hi... I have a Table in that i have inserted the DATE as VARCHAR now in that i Want to get the Max Date. I am new to MySQL Plz help me how to find the max date. with regard Inbaraj.D
5
by: sbettadpur | last post by:
hello Let me explain first the table structure. table - > pds fields - >District_ID, W_ID, Commodity_ID, Distribution_Cat_ID, Date, OB, Closing_Stock here i want the Closing_Stock value...
10
by: janieavis | last post by:
If I run this query I can see there are 2 records with the dates 10 August 2009 and 24 August 2009: SELECT dbo_JobMain.BpaMainPKey, dbo_JobMain.JobDefinitionPKey, dbo_JobMain.Value,...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.