如何让人们如何只有IN状态 [英] How to get the people how is only having IN status
本文介绍了如何让人们如何只有IN状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好
LogId | ParentId | 状态 | <期> |
---|---|---|---|
1 | 空 | 1 | 30 |
2 | 1 | 2 | 30 |
3 | Null | 1 | 31 |
4 | 3 | 2 | 31 |
5 | 3 | 2 | 31 |
6 | Null | 1 | 32 | 7 | Null | 1 | 32 |
8 | < td> 72 | 32 | |
9 | Null | 1 | 33 |
10 | 9 | 2 | 33 |
11 | Null | 1 | 33 |
12 | Null | 1 | 34 |
这是表结构LogId具有用于命令30的INPUNCH,其OUTPUNCH是具有其相应INPUNCH的ParentId的logid 2。这里重复将发生几个日志。我需要的结果是对只有INPUNCH和No OUTPUNCH的人的预约。
结果:AppoinmentId-33,34我需要一个sql查询。 ..提前谢谢。
Hi
LogId | ParentId | Status | AppoinmentId |
---|---|---|---|
1 | Null | 1 | 30 |
2 | 1 | 2 | 30 |
3 | Null | 1 | 31 |
4 | 3 | 2 | 31 |
5 | 3 | 2 | 31 |
6 | Null | 1 | 32 |
7 | Null | 1 | 32 |
8 | 7 | 2 | 32 |
9 | Null | 1 | 33 |
10 | 9 | 2 | 33 |
11 | Null | 1 | 33 |
12 | Null | 1 | 34 |
Here is table structure LogId has INPUNCH for appoinment 30 and its OUTPUNCH is logid 2 with ParentId of its corresponding INPUNCH. here duplication will happens for few logs. the result which i required was appointmentId of the people whose is having only INPUNCH and No OUTPUNCH.
Result:AppoinmentId-33,34 i need a sql query for this... thanks in advance.
推荐答案
select appointmentid from table1 t1 where
logid = (select max(logid) from table1 t3 where t3.appointmentid = t1.appointmentid)
and
parentid is null
怎么样
how about
select AppoinmentId from Table1
group by AppoinmentId having count(*) =1
这篇关于如何让人们如何只有IN状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文