Senin, 16 September 2019

Re: [MS_AccessPros] Combine 2 queries into one question

 

Duane,

Thank You, that was it.

Jim Wagner


On Monday, September 16, 2019, 1:48:16 PM MST, Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:


 

Hi Jim,
I expect you could use a single query with a subquery in the criteria:

SELECT
FROM [PSS DATA]
WHERE ID = (SELECT Max(ID) FROM [PSS DATA]);

Regards,
Duane


From: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com> on behalf of luvmymelody@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: Monday, September 16, 2019 2:26 PM
To: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com>
Subject: [MS_AccessPros] Combine 2 queries into one question
 


Hello all,

I have 2 queries that make a table that gets the max of an id and last balance in a table. I find it difficult to understand why I cannot do this in one query. The first query is a select query that gets the max of the id in the PSS DATA table. Below are the sql statements. Is there a way to combine these queries into one? I have tried the below under Query1 but it does not give me the last balance. I do get a balance but it is a balance 5 records from the last record. and the max Id is correct just not the last balance

Thank You

Jim Wagner

Query1

SELECT Last([PSS DATA].BALANCE) AS LastOfBALANCE
FROM [PSS DATA];



CURRENT PROCESS

qry_updateBegBalance1

SELECT Max([PSS DATA].ID) AS MaxOfID
FROM [PSS DATA];

The second query is a make table that uses the the qry_updateBegBalance1 query and the PSS DATA table to make a table named tempBalanceTotal.

qry_updateBegBalance2

SELECT [PSS DATA].BALANCE INTO tempBalanceTotal
FROM qry_updateBegBalance1 INNER JOIN [PSS DATA] ON qry_updateBegBalance1.MaxOfID = [PSS DATA].ID;




__._,_.___

Posted by: Jim Wagner <luvmymelody@yahoo.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (3)

.

__,_._,___

Tidak ada komentar:

Posting Komentar