473,503 Members | 2,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Last not null value

4 New Member
Hi,

What kind of query I should do if I have table like below and I want to get last written values both tanks? Not null values ( - equals null values).

id date tank number1 number2 number3
1 28.3.2007 1 1 1 1
2 28.3.2007 2 2 2 2
3 29.3.2007 1 3 - -
4 30.3.2007 1 - 4 -

So I want query to give me answers like below:

date tank number1 number2 number3
28.3.2007 2 2 2 2
30.3.2007 1 3 4 1

I know how to get query to give me id 4 and 2. But id 4 doesn't contain all values. Number1 and number2 is null value.

Thanks!
Mar 28 '07 #1
8 5029
Rabbit
12,516 Recognized Expert Moderator MVP
Have criteria in each of the number fields that excludes "-"
Mar 28 '07 #2
Keijo82
4 New Member
Have criteria in each of the number fields that excludes "-"
Thanks for your answer!

I don't quite understand what you are saying? What kind of criteria should I use? If I use "is not null" query only give me id 2 row. And I think thats because there is null values in last tank 1 row.

You probably meant something else...
Mar 28 '07 #3
Rabbit
12,516 Recognized Expert Moderator MVP
Thanks for your answer!

I don't quite understand what you are saying? What kind of criteria should I use? If I use "is not null" query only give me id 2 row. And I think thats because there is null values in last tank 1 row.

You probably meant something else...
Technically, none of your examples had null values. A null value is the absense of a value. Rather, you have the character "-" making it non null. So for the criteria, you can use Is Not Null. You have to use Not "-"
Mar 28 '07 #4
Keijo82
4 New Member
Technically, none of your examples had null values. A null value is the absense of a value. Rather, you have the character "-" making it non null. So for the criteria, you can use Is Not Null. You have to use Not "-"
I'm sorry. I meant that in real table there is null values and in example table which I post in this topic "-" means null value. I have to put something in example table because else numbers would been in wrong column like below:

id date tank number1 number2 number3
1 28.3.2007 1 1 1 1
2 28.3.2007 2 2 2 2
3 29.3.2007 1 3
4 30.3.2007 1 4

Number 4 should be in number 2 column.
Mar 28 '07 #5
Rabbit
12,516 Recognized Expert Moderator MVP
Sorry, my fault, I misunderstood what you wanted. Create 3 calculated fields for the 3 numbers.
Expand|Select|Wrap|Line Numbers
  1. Number1: DLookup("Number1", "[Table Name]", "id = " & DMax("id", "[Table Name]", "Number1 Is Not Null And Tank = " & Tank))
Repeat 2 more times for the other 2 numbers.
Mar 28 '07 #6
Keijo82
4 New Member
Sorry, my fault, I misunderstood what you wanted. Create 3 calculated fields for the 3 numbers.
Expand|Select|Wrap|Line Numbers
  1. Number1: DLookup("Number1", "[Table Name]", "id = " & DMax("id", "[Table Name]", "Number1 Is Not Null And Tank = " & Tank))
Repeat 2 more times for the other 2 numbers.
Thank you Rabbit!

That's working fine in my test table. But there's problem with the real data. In real program I have to use two tables (union). Table1 have like 10000 records and table2 have only 5000 records. I have to find last value so if I use id query always find values in table1. And other problem is that sometimes users write down newest date first and then day older and so on. That happens often after weekend. They first write sunday values and then saturday and friday. If I now use Dmax function and id there could come old data. Friday values even if there is newer value in sunday. Can you help me with this. I think I have to use date not id to get this work. I tried but could not understand what to do...

Real world is never as "easy" as test world
Mar 29 '07 #7
NeoPa
32,557 Recognized Expert Moderator MVP
Keijo,
What do values 1, 2 & 3 refer to?
Why do you have three values stored in each record rather than each stored in its own record (with maybe a type field to differentiate between them)?
It is possible to work it the way you currently have the data stored but it's much harder as that's not how Access is designed to work.
Mar 29 '07 #8
Rabbit
12,516 Recognized Expert Moderator MVP
Thank you Rabbit!

That's working fine in my test table. But there's problem with the real data. In real program I have to use two tables (union). Table1 have like 10000 records and table2 have only 5000 records. I have to find last value so if I use id query always find values in table1. And other problem is that sometimes users write down newest date first and then day older and so on. That happens often after weekend. They first write sunday values and then saturday and friday. If I now use Dmax function and id there could come old data. Friday values even if there is newer value in sunday. Can you help me with this. I think I have to use date not id to get this work. I tried but could not understand what to do...

Real world is never as "easy" as test world
There's going to be no way to do this with the current setup. You'll need them to write down the date AND time for each record they enter. Then can you find the most current number.

Right now you only have date. Multiple records with the same date, how can you ever know which one is the most recent?
Mar 29 '07 #9

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

Similar topics

3
27739
by: John Morgan | last post by:
In an SQL statement which concatenates several fields I get a null value returned if any one of the fields are null. Is this to be expected? For example : SELECT tblMember.memberAddress + '...
3
13520
by: Lynn | last post by:
Hi all, I am having problem when did the validation of XML document with Schema. my schema is like the following: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="schema.xsd"...
3
7049
by: Robb Gilmore | last post by:
Hello, We have a C#.NET app which is calling a Java webservice. We use the wsdl file exportted from the java webservice to create our web-reference in Visual Studio. We are able to create the...
15
29192
by: TC | last post by:
What does it mean for an integer to have a null value? I am trying to use the DataView.Find method. That method has an integer return type which contains the "index of the row in the DataView...
26
30886
by: Martin R | last post by:
Hi, How to find first not null value in column whitout chacking whole table (if there is a not null value then show me it and stop searching, the table is quite big)? thx, Martin *** Sent...
5
31995
by: Veeru71 | last post by:
Given a table with an identity column (GENERATED BY DEFAULT AS IDENTITY), is there any way to get the last generated value by DB2 for the identity column? I can't use identity_val_local() as...
4
2114
by: Eric Layman | last post by:
Hi everyone, Im puzzled by a NULL behaviour in SQL 2000 server. There is a column in the table that does not allow NULL. During data mining, the staff noted that, for that particular column,...
0
3046
prabirchoudhury
by: prabirchoudhury | last post by:
CRITERIA; +-------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+-------+...
2
14641
by: qwedster | last post by:
Folk! How to programattically check if null value exists in database table (using stored procedure)? I know it's possble in the Query Analyzer (see last SQL query batch statements)? But how...
0
7205
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,...
0
7093
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
7468
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...
0
5596
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,...
1
5023
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...
0
3180
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...
0
1521
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 ...
1
747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
401
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...

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.