[postgresql]高分求一个sql
问题如下:
表A
CREATE TABLE student_new
(
pkey1 int4 NOT NULL,
pkey2 varchar(20) NOT NULL,
attend_year int4,
attend_grade int4,
attend_class text,
attend_no int4,
former_year int4,
former_grade int4,
former_class text,
former_no int4,
CONSTRAINT student_new_pkey PRIMARY KEY (pkey1, pkey2)
)
例: 表A1:pkey1 pkey2 attend_year attend_grade attend_class attend_no attend_year attend_grade attend_class attend_no
1 BMW 2008 3 班级3 3 2007 2 班级2 2
要求查询结果如下:
pkey1 pkey2 year grade class no
1 BMW 2008 3 班级3 3
1 BMW 2007 2 班级2 2
谢谢!
表A
CREATE TABLE student_new
(
pkey1 int4 NOT NULL,
pkey2 varchar(20) NOT NULL,
attend_year int4,
attend_grade int4,
attend_class text,
attend_no int4,
former_year int4,
former_grade int4,
former_class text,
former_no int4,
CONSTRAINT student_new_pkey PRIMARY KEY (pkey1, pkey2)
)
例: 表A1:pkey1 pkey2 attend_year attend_grade attend_class attend_no attend_year attend_grade attend_class attend_no
1 BMW 2008 3 班级3 3 2007 2 班级2 2
要求查询结果如下:
pkey1 pkey2 year grade class no
1 BMW 2008 3 班级3 3
1 BMW 2007 2 班级2 2
谢谢!
...全文
相关推荐
postgresql sql批量更新记录
在PostgreSQL数据库中,SQL语句通常用于对数据进行增、删、查、改操作。在处理大量数据时,批量更新记录可以显著提高效率并减少网络传输的开销。
SQL Server 2012链接服务器到PostgreSQL
以下是一个详细步骤,说明如何在SQL Server 2012中配置链接服务器以连接到PostgreSQL:1.
postgresql查询死锁以及杀死死锁进程sql.txt
"本文档提供了解决PostgreSQL数据库中死锁问题的方法,包括查询死锁进程和杀死这些进程的SQL语句。"在PostgreSQL数据库系统中,死锁是多线程并发操作时可能出现的一种情况,当两个或
PostgreSQL运行SQL代码-方法+源代码
这些工具提供了一个直观的界面,用于编写、执行SQL查询,管理数据库对象,以及查看结果集。安装并启动工具后,通过连接设置连接到PostgreSQL服务器,然后在查询编辑器中输入SQL代码。3.
PostgreSQL DBA认证 PGCE-E-092-中级SQL题目
SQL题目是一个测试SQL掌握程度的题目,涵盖了PostgreSQL数据库管理系统的各种知识点。


