473,624 Members | 2,615 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Query for Last Date in a table

oszapped
1 New Member
I am new to creating SQL queries and need some help.

I am trying to query from three tables.
1 - A table with a list of Drawings (DRAWINGS)
2 - A table with the Revision history of the Drawings (REVISIONS)
3 - A table with the list of Projects (WRI_SITE_PRJS)

The result I am looking for:
Name of Drawing (I want to return the drawings that don't have a revision as well)
Last Drawing Revision
Date of Revision
Project that the drawing belongs on

The below query I created in access and the result was exactly what I was expecting.

SELECT DRAWINGLIST.NAM E, DRAWINGLIST.WRI _DESCRIPTION AS [Drawing Title], LastRev.LastOfR EVISIONNAME AS Rev, LastDate.LastOf REVISIONDATE AS [Rev Date], WRI_SITE_PRJS.T ITLE AS Project
FROM LastRev RIGHT JOIN (LastDate RIGHT JOIN (DRAWINGLIST INNER JOIN WRI_SITE_PRJS ON DRAWINGLIST.WPR JID = WRI_SITE_PRJS.W PRJID) ON LastDate.NAME = DRAWINGLIST.NAM E) ON LastRev.NAME = DRAWINGLIST.NAM E
ORDER BY DRAWINGLIST.NAM E;

I tried getting the same result in SQL and find that I can't GROUP BY the LAST date in a table. The result I'm getting is all the revisions for the drawing.

My question is: How do I query for the LAST date or revision in a table.

I'm using Microsoft SQL Server 2003

Some help is greatly appreciated.
OS
Jul 26 '07 #1
2 7632
Taftheman
93 New Member
I am new to creating SQL queries and need some help.

I am trying to query from three tables.
1 - A table with a list of Drawings (DRAWINGS)
2 - A table with the Revision history of the Drawings (REVISIONS)
3 - A table with the list of Projects (WRI_SITE_PRJS)

The result I am looking for:
Name of Drawing (I want to return the drawings that don't have a revision as well)
Last Drawing Revision
Date of Revision
Project that the drawing belongs on

The below query I created in access and the result was exactly what I was expecting.

SELECT DRAWINGLIST.NAM E, DRAWINGLIST.WRI _DESCRIPTION AS [Drawing Title], LastRev.LastOfR EVISIONNAME AS Rev, LastDate.LastOf REVISIONDATE AS [Rev Date], WRI_SITE_PRJS.T ITLE AS Project
FROM LastRev RIGHT JOIN (LastDate RIGHT JOIN (DRAWINGLIST INNER JOIN WRI_SITE_PRJS ON DRAWINGLIST.WPR JID = WRI_SITE_PRJS.W PRJID) ON LastDate.NAME = DRAWINGLIST.NAM E) ON LastRev.NAME = DRAWINGLIST.NAM E
ORDER BY DRAWINGLIST.NAM E;

I tried getting the same result in SQL and find that I can't GROUP BY the LAST date in a table. The result I'm getting is all the revisions for the drawing.

My question is: How do I query for the LAST date or revision in a table.

I'm using Microsoft SQL Server 2003

Some help is greatly appreciated.
OS

I have never used SQL Server 2003
but i would pressume it would be order by LastDate.LastOf REVISIONDATE DESC
Aug 3 '07 #2
azimmer
200 Recognized Expert New Member
I am new to creating SQL queries and need some help.

I am trying to query from three tables.
1 - A table with a list of Drawings (DRAWINGS)
2 - A table with the Revision history of the Drawings (REVISIONS)
3 - A table with the list of Projects (WRI_SITE_PRJS)

The result I am looking for:
Name of Drawing (I want to return the drawings that don't have a revision as well)
Last Drawing Revision
Date of Revision
Project that the drawing belongs on

The below query I created in access and the result was exactly what I was expecting.

SELECT DRAWINGLIST.NAM E, DRAWINGLIST.WRI _DESCRIPTION AS [Drawing Title], LastRev.LastOfR EVISIONNAME AS Rev, LastDate.LastOf REVISIONDATE AS [Rev Date], WRI_SITE_PRJS.T ITLE AS Project
FROM LastRev RIGHT JOIN (LastDate RIGHT JOIN (DRAWINGLIST INNER JOIN WRI_SITE_PRJS ON DRAWINGLIST.WPR JID = WRI_SITE_PRJS.W PRJID) ON LastDate.NAME = DRAWINGLIST.NAM E) ON LastRev.NAME = DRAWINGLIST.NAM E
ORDER BY DRAWINGLIST.NAM E;

I tried getting the same result in SQL and find that I can't GROUP BY the LAST date in a table. The result I'm getting is all the revisions for the drawing.

My question is: How do I query for the LAST date or revision in a table.

I'm using Microsoft SQL Server 2003

Some help is greatly appreciated.
OS
Use Max() on the date column and group by everything else.
Aug 6 '07 #3

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

Similar topics

3
323
by: Pakku | last post by:
This is on DB2 V7 on OS/390 I have 2 tables PATIENT and SPECIMEN. PATIENT columns are IDENTIFICATION LAST NAME FIRST NAME SPECIMEN columns are SPECIMEN_NUMBER (this is a manufactured column made up by concatenating
2
2536
by: Willem | last post by:
Hi there, I'm sort of new with doing much record manipulation with queries. Up till now I've been programming VBA and doing record looping to get my results. This works fine but tends to get very, very slow as the number of records grows - somewhere in the number of 5,000,000. I imagine queries are much faster but am not quite sure if queries will do the trick. My problem:
4
7741
by: Apple | last post by:
1. I want to create an autonumber, my requirement is : 2005/0001 (Year/autonumber), which year & autonumber no. both can auto run. 2. I had create a query by making relation to a table & query, but I can't update record in query or in form. I believe the problem is due to the source query. In source query, there is a filter to show the incomplete record ("is null" in delivery date)], but I need to re-use the job no. if the job is...
3
2092
by: Serious_Practitioner | last post by:
Good day, and thank you in advance for any assistance you can provide. I have a table in an Access 2000 .mdb file, and I've run into something odd and insolvable, at least for me. The database is for membership information. This particular table, called tblMembershipInfo, has fields/columns as follows - fldMemNum - Member Number fldActionDate - The date when the entry was made in that row - Data type is Date/Time, no format specified
2
4160
by: dauwe.peter | last post by:
A table : Nameperson, Book nr, Bookdatein, Bookdateout, CD nr, cddatein, cddateout, dvd nr, dvddatein, dvddateout. I would like a query where a see the personsname en de last book with the datein and out , the last cd with datein and out , and the same for the dvd. Because the last time the person came he toke only a book but dit not return his dvd (for example). But with one click i would like to see the last of every item with the...
1
3707
by: bruce24444 | last post by:
First of all I'm new to the forum and am working on my first database. So far I think I've done not too bad but have hit a stumbling block for which I'm not sure how to get around. What I have is a database which tracks assigned files to a certain people which is generated by a form and then recorded into a table. Tables are as follows “Staff” “Loss_Type” and “Claims_Assignment”. From this “Claim_Assignment” table I have created separate...
4
31251
by: kdubble | last post by:
Hi I am trying to get the results of a query to show only unique student records (not duplicates). Is there a simple way to make the criteria field do this? I am not too familiar with SQL. I have a student_info table, a session_info table, and a services_to_students table. What I'd like to do is query the tables to get a list of all students served between certain dates. Now, of course, between those dates,
2
3098
by: scott | last post by:
Hi Everyone, I have a table which has many fields in it but I need to pull some specific info via a query and I don't know if it's possible. I want to run a query which includes two tables. Participants and Payments. They are linked so that a participant can make many payments and a report can then be printed on all payments that participant has made. What I want to do is have a field in the payments table that has a "PaidTo"
12
2438
by: Michel Esber | last post by:
Hello, Db2 Linux LUW FP 15. Consider table A (ID varchar, EXECUTION_DATE date). a) I want to first retrieve all IDs that have not executed during the last 90 days: select distinct ID from table_B where NOT EXISTS
0
8179
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
8631
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8341
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
7174
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...
1
6112
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
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();...
0
4084
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4184
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1489
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.