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

Simple / Complicated Query?

Hi,

I am trying to create a query from a table which has an ID, Diary and
Date fields.
A particular ID may have several diary entries which all have their
specific date.

What I'm after is a query that will show me only the previous 3 diary
entries sorted by date.

Any thoughts would be greatly appreciated

Thanks
Zieshan
Jun 27 '08 #1
3 1122
On May 30, 2:21*am, z.ghu...@gmail.com wrote:
Hi,

I am trying to create a query from a table which has an ID, Diary and
Date fields.
A particular ID may have several diary entries which all have their
specific date.

What I'm after is a query that will show me only the previous 3 diary
entries sorted by date.

Any thoughts would be greatly appreciated

Thanks
Zieshan
It goes something like this (change field names to match your table
field names):

SELECT tblDiary.ID, tblDiary.Diary, tblDiary.Date
FROM tblDiary
WHERE tblDiary.Date In (SELECT TOP 3 tblDiary.Date
FROM tblDiary
GROUP BY tblDiary.Date);

Regards,
Branislav Mihaljev
Microsoft Access MVP
Jun 27 '08 #2
Thanks for that.

I've tried it out, but this brings up only 3 results. What I'm after
is 3 diary entries for each Issue Ref?
I've tried playing about with it, but to be honest my SQL skills are
pretty poor.
Can you help?

Cheers
Zieshan
Jun 27 '08 #3
On May 31, 12:04*am, z.ghu...@gmail.com wrote:
Thanks for that.

I've tried it out, but this brings up only 3 results. What I'm after
is 3 diary entries for each Issue Ref?
I've tried playing about with it, but to be honest my SQL skills are
pretty poor.
Can you help?

Cheers
Zieshan
Probably you have done something wrong. Using these data:

Diary, Date
a, 01/01/2008
b, 01/01/2008
c, 02/01/2008
d, 03/01/2008
e, 03/01/2008
f, 04/01/2008
g, 04/01/2008
h, 04/01/2008
i, 04/01/2008

above query returns:

Diary, Date
a, 01/01/2008
b, 01/01/2008
c, 02/01/2008
d, 03/01/2008
e, 03/01/2008

Five records in total, but only for top 3 dates.

Regards,
Branislav Mihaljev
Microsoft Access MVP
Jun 27 '08 #4

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

Similar topics

0
by: Jesse Sheidlower | last post by:
I'm struggling with speed issues on some queries that I would have expected to be relatively fast. Perhaps even more frustratingly, when I've tried to break these down into their components, they...
10
by: jqq | last post by:
SQL2K on W2Kserver I need some help revamping a rather complicated query. I've given the table and existing query information below. (FYI, changing the database structure is right out.) The...
1
by: Philip | last post by:
Hey everyone, I've got a real newbie question and I'll try to make some sense as I explain it. I've got a three tables for simplification. SCREENS (screens names) CONTROLS (control names)...
3
by: Iain Miller | last post by:
Can anybody help me with some Access 2000 code? I don't do a lot of coding in Access & so every time I come back to do something I pretty much have to relearn the syntax from scratch so this is...
15
by: Richard Hollenbeck | last post by:
For example, one college course has only 24 students in it, but the following code says there are zero As, 20 Bs, 16 Cs, 4 Ds, and 8 Fs. When it prints it then says 0 As, 40 Bs, 32 Cs, 8 Ds, and...
26
by: Jeff | last post by:
Ok gang. Here is something complicated, well, at least to me anyway. Using Access DB I have a table in my DB called members. In that table, I have 2 tables I will be using "username" and...
5
by: TonyJH | last post by:
Hi. I'm new to this database world. Just started Access training a few months ago and have a somewhat complicated database already built. In a nutshell, I have a select query that uses a parameter...
1
by: DougJrs | last post by:
Good Morning, I am trying to write a simple function that would grab the "errorId" parameter and then display a message when the page loads. I basically have a login page (login.asp) that if...
4
by: Paul Furman | last post by:
I've set up a web gallery with 6 thumbnails per page, etc with php which is a big complicated mess because I'm not a brilliant programmer... it is the outgrowth of a couple classes I took at a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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...
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,...

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.