每日打卡-31
Posted leapssisbird
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了每日打卡-31相关的知识,希望对你有一定的参考价值。
一.问题描述
已知Horse类是Pegasus类的父类,根据以下主函数完善程序内容,以实现规定的输出。不允许改变主函数的内容。
int main()
Horse *p1 = new Horse; //输出:Horse 申请了空间...
Horse *p2 = new Pegasus; /* 输出两行:
Horse 申请了空间...
Pegasus 申请了空间...
*/
cout << endl;
p1->Fly(); //输出:Just a horse.
p2->Fly(); //输出:I can fly!
cout << endl;
delete p1; //输出:Horse 释放了空间...
delete p2; /* 输出两行:
Pegasus 释放了空间...
Horse 释放了空间...
*/
return 0;
二.设计思路
三.流程图
四.伪代码
1
五.代码实现
#include<iostream>
using namespace std;
class Horse
public:
Horse() cout << "Horse 申请了空间..." << endl;
virtual ~Horse() cout << "Horse 释放了空间..." << endl;
virtual void Fly()
cout << "Just a horse." << endl;
;
class Pegasus :public Horse
public:
Pegasus() cout << "Pegasus 申请了空间..." << endl;
~Pegasus() cout << "Pegasus 释放了空间..." << endl;
void Fly()
cout << "I can fly!" << endl;
;
int main()
Horse* p1 = new Horse; //输出:Horse 申请了空间...
Horse* p2 = new Pegasus; /* 输出两行:
Horse 申请了空间...
Pegasus 申请了空间...
*/
cout << endl;
p1->Fly(); //输出:Just a horse.
p2->Fly(); //输出:I can fly!
cout << endl;
delete p1; //输出:Horse 释放了空间...
delete p2; /* 输出两行:
Pegasus 释放了空间...
Horse 释放了空间...
*/
return 0;
SQL 统计每日上班打卡和下班打卡语句
有以上员工打卡记录表
其中
Card_No为考勤卡号
Atte_time 为打卡时间
DoorInout为上班或下班,1为上班,0位下班
想统计没人每天最早上下班打卡,和其他上下班打卡 各去4笔 如不足则为空
如以下样式的表
-----------------------------------------
考勤卡号 日期 上班打卡 上班打卡1 上班打卡2 上班打卡3 下班打卡 下班打卡1 下班打卡2 下班打卡310890895 2013-08-10 16:04 20:24 NULL NULL 19:43 2013-08-11 00:46 NULL NULL10890895 2013-08-11 16:04 19:45 20:18 NULL NULL NULL NULL NULL
如果下班在第二天3点以内的也统计入下班打卡中下班打卡早于最早上班打卡的数据忽略
CREATE TABLE AtteTime
(
Card_No VARCHAR(10) ,
Atte_Time DATETIME ,
DoorInOut BIT
)
select A1.card_no,
A1.atte_time as "上班时间",
A2.atte_time as "上班时间1",
A3.atte_time as "上班时间2",
A4.atte_time as "上班时间3",
B1.atte_time as "下班时间",
B2.atte_time as "下班时间1",
B3.atte_time as "下班时间2",
B4.atte_time as "下班时间3"
from (select card_no, atte_time
from (select card_no,
atte_time,
ROW_NUMBER() over(partition by card_no order by atte_time) as In_ID
from attetime
where doorinout = 1) T
where T.In_ID = 1) A1
left join (select card_no, atte_time
from (select card_no,
atte_time,
ROW_NUMBER() over(partition by card_no order by atte_time) as In_ID
from attetime
where doorinout = 1) T
where T.In_ID = 2) A2
on A1.card_no = A2.card_no
left join (select card_no, atte_time
from (select card_no,
atte_time,
ROW_NUMBER() over(partition by card_no order by atte_time) as In_ID
from attetime
where doorinout = 1) T
where T.In_ID = 3) A3
on A1.card_no = A3.card_no
left join (select card_no, atte_time
from (select card_no,
atte_time,
ROW_NUMBER() over(partition by card_no order by atte_time) as In_ID
from attetime
where doorinout = 1) T
where T.In_ID = 4) A4
on A1.card_no = A4.card_no
full join (select card_no, atte_time
from (select card_no,
atte_time,
ROW_NUMBER() over(partition by card_no order by atte_time desc) as Out_ID
from attetime
where doorinout = 0) T
where T.Out_ID = 1) B1
on A1.card_no = B1.card_no
left join (select card_no, atte_time
from (select card_no,
atte_time,
ROW_NUMBER() over(partition by card_no order by atte_time desc) as Out_ID
from attetime
where doorinout = 0) T
where T.Out_ID = 2) B2
on A1.card_no = B2.card_no
left join (select card_no, atte_time
from (select card_no,
atte_time,
ROW_NUMBER() over(partition by card_no order by atte_time desc) as Out_ID
from attetime
where doorinout = 0) T
where T.Out_ID = 3) B3
on A1.card_no = B3.card_no
left join (select card_no, atte_time
from (select card_no,
atte_time,
ROW_NUMBER() over(partition by card_no order by atte_time desc) as Out_ID
from attetime
where doorinout = 0) T
where T.Out_ID = 4) B4
on A1.card_no = B4.card_no
投入验证数据如下:
执行结果如下:
参考技术A 这是在oracle数据库下做的,不知道你是什么数据库,给你提供一下思路select
card_no,
attr_date,
to_char(atte_time,'HH24:MI')tim,
doorinout,
rn
from (
select
card_no,
attr_date,
atte_time,
doorinout,
ROW_NUMBER() OVER(PARTITION BY card_no,attr_date,doorinout ORDER BY atte_time asc) rn
from(
select
card_no,
(
case
when doorinout=1
then to_date(to_char(atte_time,'yyyy-MM-dd'),'yyyy-MM-dd')
when (doorinout=0 and to_number(to_char(atte_time,'HH24'))<3)
then (to_date(to_char(atte_time,'yyyy-MM-dd'),'yyyy-MM-dd')-1)
else to_date(to_char(atte_time,'yyyy-MM-dd'),'yyyy-MM-dd')
end
)attr_date,
atte_time,
doorinout
from AtteTime
) tmp order by card_no,atte_time asc,doorinout desc
) where rn < 5 参考技术B 能不能来一份数据 这么凭空想 或者构造数据 太麻烦 一些代表性的数据 就行。还有问题要描述清楚 :1)各 取 4笔还是各 去 4 笔,少了为空,多了呢?取时间早的还是时间晚的。
2) 没人每天是什么意思
3) 不经过调试 谁也不能保证自己写出的语句是100%正确的,给点代表性的数据。追问
上班,下班各去4笔数据,少了留空,多了去出去最早前4笔
每人每天的数据意思就是按照考勤号和日期进行分组
数据:字数限制放不上来
给分代表性的数据 错别字还是少点好
追问数据字数太长了放不上来,百度HI上给你吧.
以上是关于每日打卡-31的主要内容,如果未能解决你的问题,请参考以下文章