473,806 Members | 2,653 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1140
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
486
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 still execute very slowly. I've looked over all the relevant suggestions for optimization and so forth, and there's nothing I can tell that I'm missing. An example of a query is to get all the words (the cg.cw field) in a particular...
10
2457
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 current query lists addresses with two particular types ('MN30D843J2', 'SC93JDL39D'). I need to change this to (1) check each contact for address type 'AM39DK3KD9' and then (2) if the contact has type 'AM39DK3KD9' select types ('AM39DK3KD9',...
1
1653
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) SCREEN PAGES (page text)
3
2175
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 taking me hours. As with most occasional programmers its the commas, colons, inverted commas, square brackets etc etc that cause the problem! (Not to mention the nuances of using Do While, Do until, Case statements If statements, IIF etc etc...)...
15
2024
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 16 Fs. The actual number it should show is zero As, 10 Bs, 8 Cs, 2 Ds, and 4 Fs. I can't find anything wrong with the code. Here it is: Option Compare Database Option Explicit 'global variables
26
2182
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 "points" Now, I also have a table called all_matches. This table contains every match report. Over 25,000 of them. I have a "username" field an "outcome" field an "username1" field and "extra_match" field.
5
1783
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 callout so the user can enter a serial number of a widget and get test information for a report. The query pops out the test data in, for simplicity, in two columns, rest result Type A and Type B. The challenge for me is getting the results broken...
1
1583
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 the login fails the user is directed page to the login page with an errorId parameter (login.asp? errorId=1). I wrote the javascript below to grab the paramater and then retuen a message (I borrowed the gup function from an example, and wrote the
4
1424
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 community college & not my main career... anyways someone asked me to set up something like that for their web site and I'm wondering if there is a simpler php package to accomplish this task. I prepare thumbnails in a subfolder named thumbs and put...
0
9719
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10371
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
10373
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
10111
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9192
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
7650
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
5683
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3010
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.