请大家帮个忙

evonne0102 2008-01-16 09:26:16
现在有个表:A(id ,name,regdate), B(id,groupid),C(id,name2)
regdate注册日期(格式为2007/02/12)
Name姓名
写出下面的SQL语句
1).统计A表中每个月注册用户数
2).统计A表中有姓名相同的用户数
3).如果表A中有姓名相同的用户,把相同的查出,写入表C中
4).A中ID有多个相同的数据,A中姓名相同的ID只保留注册时间最大的数据
...全文
196 5 打赏 收藏 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
dawugui 2008-01-16
  • 打赏
  • 举报
回复
1).统计A表中每个月注册用户数 
select convert(varchar(10),regdate,120) 年月 , count(*) 注册用户数 from A group by convert(varchar(10),regdate,120)

2).统计A表中有姓名相同的用户数
select count(*) 姓名相同的用户数 from
(
select name from a group by name having count(*) > 1
) t

3).如果表A中有姓名相同的用户,把相同的查出,写入表C中
insert into c(name) select name from a group by name having count(*) > 1

4).A中ID有多个相同的数据,A中姓名相同的ID只保留注册时间最大的数据
delete a from a t where regdate not in (select max(regdate) from a where name = t.name)

pt1314917 2008-01-16
  • 打赏
  • 举报
回复

--1)
select convert(varchar(7),regdate,120)[日期],count(1)[数量] from A group by convert(varchar(7),regdate,120)

--)2
select name,count(1)[数量] from A group by name

--3)
如果c表的id为自增的话:
insert into c select name from a group by name having count(1)>1

--4)
select * from A t where not exists(select 1 from A where name=a.name and regdate>a.regdate)
marco08 2008-01-16
  • 打赏
  • 举报
回复
考试题目?
liangCK 2008-01-16
  • 打赏
  • 举报
回复
4
select *
from tb a
where not exists(select 1 from tb
where id=a.id and name=a.name and regdate>a.regdate)
liangCK 2008-01-16
  • 打赏
  • 举报
回复
1
select convert(char(7),regdate,120) regdate,count(*) cnt
from tb
group by convert(char(7),regdate,120)

2
select name,count(*) cnt
from tb
group by name

3
insert into c
select name
from tb a
where exists(select 1 from tb where a.name=name and a.id>id)
源码链接: https://pan.quark.cn/s/a4b39357ea24 微信小程序是由腾讯公司设计的一种轻量级应用开发平台,主要面向移动设备,旨在为用户带来无需下载安装即可直接使用的应用服务体验。在微信小程序的开发实践中,"模仿美团菜单 swiper分类菜单"是一项常见的技术应用,其目的是达成与美团外卖应用相似的交互模式,使用户能够轻松地浏览和挑选各种商品或服务。 在微信小程序的技术体系中,`swiper`组件属于轮播图功能模块,通常用于呈现多张图片或卡片式的切换界面,能够达成动态滑动展示不同分类菜单的功能。在模拟美团菜单的应用情境下,`swiper`组件一般与`swiper-item`组件协同工作,每一个`swiper-item`对应一个分类,用户可通过左右滑动来切换不同的分类菜单。 为了达成这样的功能,首先需要在微信小程序的`json`配置文档中引入`swiper`组件,并在`wxml`结构文档中构建相应的布局代码,将每个分类以`swiper-item`的形式进行组织。同时,需要在`wxss`样式文档中定义恰当的样式,保证分类菜单的视觉呈现符合设计规范。 接下来,我们将在`js`逻辑文档中处理`swiper`的切换逻辑,通过监听`bindchange`事件来识别当前选中的分类,并根据这一信息动态获取对应的子菜单信息。为了达成类似美团的层级菜单功能,可能还需要借助`picker`或`navigator`组件来展示二级分类或商品详情。 在开发阶段,需要关注以下关键点: 1. 数据绑定:保证数据与界面之间的双向链接准确无误,以便在选择分类时即时更新显示内容。 2. 动态加载:针对大量数据,可能需要采取异步加载机制,防止一次性加载过多内容引发性能瓶颈...

34,876

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧