Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2003 08:26 AM
тАО08-27-2003 08:26 AM
SQL
FROM tSi_Daily_Hist S
WHERE company_code = '0102'
AND NOT EXISTS
(SELECT prod_code
FROM tproduct P);
I have couple of prod codes available in
tSi_Daily_Hist which are NOT in tproduct.
But still above query return 0.
Anything wrong with the query?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2003 10:36 AM
тАО08-27-2003 10:36 AM
Re: SQL
maybe this question should be post to another forum, for instance
http://pipetalk.quest-pipelines.com/~dba/login
Try to give us some result from subquery or some example data ....
HTH
Radim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2003 04:51 PM
тАО08-27-2003 04:51 PM
Re: SQL
FROM tSi_Daily_Hist S
WHERE company_code = '0102'
AND NOT EXISTS
(SELECT prod_code
FROM tproduct P
where p.prod_code = s.prod_code);
Because you are issing a not exists, you need to make sure you limit it correctly.
Thanks,
Brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2003 09:03 PM
тАО08-27-2003 09:03 PM
Re: SQL
maybe the following notes on anti- and semi- joins can also help...
==============================================
A semi-join returns rows that match an EXISTS subquery, without duplicating rows from the left side of the predicate when multiple rows on the right side satisfy the criteria of the subquery. For example:
SELECT * FROM dept
WHERE EXISTS
(SELECT * FROM emp
WHERE dept.ename = emp.ename
AND emp.bonus > 5000);
An anti-join returns rows from the left side of the predicate for which there is no corresponding row on the right side of the predicate. That is, it returns rows that fail to match (NOT IN) the subquery on the right side. For example, an anti-join can select a list of employees who are not in a particular set of departments:
SELECT * FROM emp
WHERE deptno NOT IN
(SELECT deptno FROM dept
WHERE loc = 'HEADQUARTERS');
==============================================
best regards
Yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-28-2003 03:01 AM
тАО08-28-2003 03:01 AM
Re: SQL
I think you have missed prod_code in the query.
select count(S.prod_code) from tSi_Daily_Hist S WHERE company_code = '0102' AND S.prod_code NOT EXISTS ( select P.prod_code from tproduct P);
Regards
VJ.