查询多个字段值,且要求所查询的结果中某一个字段的值都不相同

青山净水 2007-05-14 06:00:13
假如有一个表A
我想从中查找字段A1,A2,A3,A4
但是要求,字段A1的值不能有相同的记录,不知如何写Select语句。
...全文
467 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
wsyplzbfdl 2007-05-17
  • 打赏
  • 举报
回复
结果
/***********
a b c
1 1 1
3 1 2
4 3 2
************/
wsyplzbfdl 2007-05-17
  • 打赏
  • 举报
回复
当然办法是最苯的了
create table #t(a int,b int,c int)
insert into #t select 1,1,1
union all select 1,1,2
union all select 3,1,2
union all select 3,1,2
union all select 4,3,2
union all select 4,4,2
union all select 4,5,2
union all select 4,6,2

declare t_cursor cursor
for select a,b,c from #t order by a
declare @a int,@b int,@c int
declare @test table(a int,b int,c int)
open t_cursor
fetch next from t_cursor into @a,@b,@c
while @@fetch_status=0
begin
if not exists(select 1 from @test where a=@a)
insert into @test select @a,@b,@c
fetch next from t_cursor into @a,@b,@c
end
select * from @test
close t_cursor
deallocate t_cursor


drop table #t
青山净水 2007-05-17
  • 打赏
  • 举报
回复
看来是没有办法实现了
青山净水 2007-05-15
  • 打赏
  • 举报
回复
谢谢楼上的关注,不过还是不行
ojuju10 2007-05-15
  • 打赏
  • 举报
回复
select a.* from a,(select a1,count(1) as num from a group by a1 ) b
where a.a1=b.a1 and b.num=1
青山净水 2007-05-15
  • 打赏
  • 举报
回复
上面的方法都不行啊
budong0000 2007-05-15
  • 打赏
  • 举报
回复
ft, look this, maybe i haven't know his request.

select * from A where A1 in (select distinct(A1) from A)
shuai45 2007-05-15
  • 打赏
  • 举报
回复
select A1,A2,A3,A4 from 表 as T
where id >(select min(id) from 表 where A1=T.A1)
bill024 2007-05-14
  • 打赏
  • 举报
回复
select * from A where A1 not in
(
select A1 from A group by A1 having(count(*))>1
)
awuniao 2007-05-14
  • 打赏
  • 举报
回复
select DISTINCT A1 from A 可以查询A1不同的值
但查不了A2,A3,A4


awuniao 2007-05-14
  • 打赏
  • 举报
回复
select DISTINCT A1,A2,A3,A4 from A
bill024 2007-05-14
  • 打赏
  • 举报
回复
select top 1 * from A where A1 in (select top 1 A1 from A )
union all
select * from A where A1 not in (select top 1 A1 from A)
bill024 2007-05-14
  • 打赏
  • 举报
回复
select top 1 * from A where A1 in (select top 1 A1 from A )
union all
select * from A t where A1 not in (select top 1 A1 from A)
本文基于国A股上市企业数据,分析了逻辑型和学习型AI技术应用对企业创新的影响。通过机器学习生成AI词典并分析年报文本,测量AI应用水平。研究发现,AI应用通过增加知识多样性、打破组织惯例和提高资源配置效率促进企业创新,且企业的吸收能力增强了这一促进作用 参照李玉花(2024)的做法,团队对来自国工业经济《人工智能技术应用如何影响企业创新》一文的基准回归部分进行复刻 团队将原文数据更新至2023年,并对基准回归进行复刻。数据年份为2007-2023年,包括原始数据、处理dofile,基准回归代码 一、数据介绍 数据名称:人工智能技术应用如何影响企业创新 数据范围:A股上市公司 数据年份:2007-2023年 有效样本:33615条 数据说明:参考《管理世界》姚加权(2024)的做法,测算人工智能水平 内含原始数据、dofile和基准回归 二、数据指标 股票代码 股票简称 年份 省份 城市 区县 省份代码 城市代码 区县代码 行业代码 行业名称 企业上市年龄_年 是否ST或金融类 总资产_万元 营业收入增长率_% 资产负债率_% 总资产收益率_% 研发投入占营业收入比例_% 人工智能词频和 人工智能词频和加1取对数 企业专利申请总量 企业发明专利申请量 企业专利授权总量 企业发明专利授权量 三、参考文献 李玉花,林雨昕,李丹丹.人工智能技术应用如何影响企业创新[J].国工业经济,2024,(10):155-173.

27,580

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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