SQL关系查询,特别是最后一个

问题描述 投票:-4回答:1

Please check this image for more details

sql model qsqlrelationaltablemodel
1个回答
0
投票
  1. 创建不同的客户表并插入不同的客户名称和不同的联系号码。

2。

a) select customer_id,c_name,c_number from (
select a.col1 customer_id,a.col2 c_name,a.col3 c_number,
ROW_NUMBER() OVER (ORDER BY a.col3 ) AS c_row_num1,
ROW_NUMBER() OVER (ORDER BY b.col3 ) AS c_row_num2
from table a
inner join table b on 
a.col1=b.col1)
where c_row_num1>5 and c_row_num2>5

b)

select customer_id,c_name,c_number from (
select a.col1 customer_id,a.col2 c_name,a.col3 c_number,
from table a
inner join table b on 
a.col1=b.col1)
where a.col3 is null and b.col3 is null

c)

select customer_id,c_name,c_number from (
select a.col1 customer_id,a.col2 c_name,a.col3 c_number,
from table a
inner join table b on 
a.col1=b.col1)
where a.col3=b.col3

我希望您已经理解我的查询。我已经为您的问题陈述提供了逻辑。

© www.soinside.com 2019 - 2024. All rights reserved.