oracle查询需要在同一个查询中进行比较并得到结果
我有一个查询,它从一个数据库中获取记录,然后使用脚本将其插入服务器之间的另一个数据库中。
查询就像:-
select id, date, iscomplete
from sourcedb.test where id = '1'
and date = '2011-03-15' and iscomplete = 1;
这个查询返回一些记录,只有当有一定数量的记录时我才需要这些记录。 例如:-“2011-03-15”有 10 条记录,那么我只想在所有 10 条记录的完成度为 1 时才获取这 10 条记录。
我不想对其进行硬编码,因为记录在不久的将来可能会从 10 条增加到 20 条。
有什么方法可以修改我的原始查询并检查当天所有记录是否 iscomplete = 1,然后获取记录,否则不返回任何内容。
我需要为此查询添加一个条件,即如果有 10 条记录,其中一半已完成,即 isComplete = 1,其中一半为 isComplete <>; 1 在这种情况下,我不希望查询有任何输出,除非所有记录都有 isComplete = 1。
问候, 玛纳西
I have a query which fetch record from one db and insert it into another db across servers using script.
the query is like :-
select id, date, iscomplete
from sourcedb.test where id = '1'
and date = '2011-03-15' and iscomplete = 1;
this query returns me some records, which i want only when there are certain number of records.
for ex:- there are 10 records for '2011-03-15' then I want to fetch those 10 records only when is complete is 1 for all the 10 records.
I dont want to hardcode it as records can increase in near future from 10 to 20.
Is there any way I can modify my original query and check if iscomplete = 1 for all the records for that day then fetch the records else return nothing.
I need to add one more condition to this query that is if there are 10 records and half of them are completed i.e. isComplete = 1 and half of them are isComplete <> 1 in this case I dont want any output from the query untill and unless all the record has isComplete = 1.
Regards,
Manasi
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需进行下一次检查
Just make the next check