Oracle问题(对于你们中的一些人来说可能很简单。) [英] Oracle question (may be simple for some of you.)
本文介绍了Oracle问题(对于你们中的一些人来说可能很简单。)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好我拿到这张桌子:
hi guys i got this table :
client type school
a 1 123
a 2 123
b 1 123
b 2 123
c 1 123
d 2 123
e 3 123
请注意,此表是为此示例创建的。
i需要让客户端知道他们的类型是1和2所以在此我希望客户a& b
我如何才能使查询只获得那2个。
我是什么尝试过:
i尝试了查询但不好:
从表格中选择不同的客户端
其中
(type = 1)或(type = 2);
please note that this table is created for this example.
i need to get thos client that their type is 1 and 2 so in this case i want clients a & b
How can i make the query to get those 2 only.
What I have tried:
i tried the query but it is not good :
select distinct client from table
where
(type = 1) or ( type = 2);
推荐答案
伙计们我找到了解决方案。
guys i found the solution for what i meant.
select distinct client from table a
join table b on
b.client = a.client
where a.type= '1'
and b.type = '2'
这将返回具有这两种类型的所有客户端。
this will return all the client that have both types.
SELECT T1.CLIENT
FROM [YOUR_TBL] T1
INNER JOIN [YOUR_TBL] T2 ON T2.CLIENT = T1.CLIENT AND T2.TYPE <> 1
WHERE
T1.TYPE = 1 AND T2.TYPE = 2
select client,type1 from school
where (type1=1 or type1=2) and (client='a' or client='b');
这篇关于Oracle问题(对于你们中的一些人来说可能很简单。)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文