473,240 Members | 1,579 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,240 software developers and data experts.

QUERY Question

I have a table that contains the following:

LOANID,PAYMENTDATE,PAIDTAG,PAYMENTAMOUNT
-----------------------------------------------------------------------------------
1 01/01/04 0 100
1 02/01/04 0 100
2 01/01/04 0 100
2 02/01/04 0 100

I need to create a VIEW that contains only 1 record for each loan id where paidtag = 0

I tried a SELECT DISTINCT query but I couldnt get it working.

SELECT DISTINCT LOANID,PAYMENTDATE,PAYMENTAMOUNT
FROM MyTable
WHERE PAIDTAG = 0

does not give me distinct records for each loan id.

Any help is appreciated.


--
Tim Morrison

--------------------------------------------------------------------------------

Vehicle Web Studio - The easiest way to create and maintain your vehicle related website.
http://www.vehiclewebstudio.com
Jul 20 '05 #1
2 1099
Is this it?

SELECT loanid, MAX(paymentdate) AS paymentdate, paymentamount
FROM MyTable
WHERE paidtag = 0
GROUP BY loanid, paymentamount

If not, please post DDL for the table and show your required result.

--
David Portas
------------
Please reply only to the newsgroup
--
Jul 20 '05 #2
Thank you. That pointed me in the right direction, and it works.

My actual query ended up being:

SELECT TOP 100 PERCENT LOANID, MIN(PAYMENTNUMBER) AS PAYMENTNUMBER,
MAX(PAYMENT) AS PAYMENT, MIN(PAYMENTDATE)
AS PAYMENTDATE
FROM dbo.AMORTSchedule
WHERE (PAIDTAG = 0)
GROUP BY LOANID
ORDER BY PAYMENTNUMBER

Thanks,

Tim

"David Portas" <RE****************************@acm.org> wrote in message
news:l8********************@giganews.com...
Is this it?

SELECT loanid, MAX(paymentdate) AS paymentdate, paymentamount
FROM MyTable
WHERE paidtag = 0
GROUP BY loanid, paymentamount

If not, please post DDL for the table and show your required result.

--
David Portas
------------
Please reply only to the newsgroup
--

Jul 20 '05 #3

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

Similar topics

9
by: majsen | last post by:
Hi, I have problem running this query. It will time out for me... My database are small just about 200 members. I have a site for swaping appartments (rental). my query should look for match in...
3
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table...
7
by: serge | last post by:
How can I run a single SP by asking multiple sales question either by using the logical operator AND for all the questions; or using the logical operator OR for all the questions. So it's always...
6
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
2
by: mmitchell_houston | last post by:
I'm working on a .NET project and I need a single query to return a result set from three related tables in Access 2003, and I'm having trouble getting the results I want. The details: ...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...

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.