由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - 急问Access Query问题:怎样查询最后一个非空的数值,谢谢
相关主题
新手请教:为什么这个Query不workSQL Server query 一问
error of sql query in MS Access database (转载)怎么写这个query呢?
A sql questionhow to write this query
[转载] Can anyone interpret this simple SQL?请问个join的问题
怎么写个query 把输出变成横排.咋样选一个表中在另一个表中不含有的记录
Help: "Operation Must Be Updatable Query"一个SQL问题
怎样解决 Index for NULL valuehow to remove fulltext index?
菜鸟问题,急Sharepoint list怎么做sumif?
相关话题的讨论汇总
话题: null话题: field1话题: field2话题: filed3话题: select
进入Database版参与讨论
1 (共1页)
l*******y
发帖数: 11
1
我的数据情况如下:
每个ID有多组重复测量的值,但是有的没有测量值
ID field1 field2 filed3
1
1 z
1 x y Null
2 a
2 Null b c
.
.
.
n
n e f
n d Null Null
想通过query得到每个field最后一个非空的数值,即:
ID field1 field2 filed3
1 x y z
2 a b c
...
n d e f
用total,last 得出的只能得到最后一组值:
ID field1 field2 filed3
1 x y Null
2 Null b c
n d Null Null
谢谢大家啦!
i****a
发帖数: 36252
2
select id, max(field1) as f1, max(field2) as f2
from table
group by id
l*******y
发帖数: 11
3
请问是用最大值(max)吗?这样能得到最后一个值吗
B*****g
发帖数: 34098
4
select t1.id, t1.f1,t2.f2,t3.f3
from (select id, last(field1) as f1
from table1
where field1 is not null
group by id) t1,
(select id, last(field2) as f2
from table1
where field2 is not null
group by id) t2,
(select id, last(field3) as f3
from table1
where field3 is not null
group by id) t3
where t1.id = t2.id
and t1.id= t3.id
or
select t0.id,
(select last(t1.field1) from table1 t1 where t1.id = t0.id and t1.fie
ld1 is not null) AS field1,
(select last(t2.field2) from table1 t2 wher

【在 l*******y 的大作中提到】
: 我的数据情况如下:
: 每个ID有多组重复测量的值,但是有的没有测量值
: ID field1 field2 filed3
: 1
: 1 z
: 1 x y Null
: 2 a
: 2 Null b c
: .
: .

l*******y
发帖数: 11
5
Thank you so much Beijing! It works!!
1 (共1页)
进入Database版参与讨论
相关主题
Sharepoint list怎么做sumif?怎么写个query 把输出变成横排.
How to write this queryHelp: "Operation Must Be Updatable Query"
怎么用sql query 实现这个功能?怎样解决 Index for NULL value
誰來幫我開來開悄? Interesting SQL query菜鸟问题,急
新手请教:为什么这个Query不workSQL Server query 一问
error of sql query in MS Access database (转载)怎么写这个query呢?
A sql questionhow to write this query
[转载] Can anyone interpret this simple SQL?请问个join的问题
相关话题的讨论汇总
话题: null话题: field1话题: field2话题: filed3话题: select