Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Compare value in cell based on 2 queries

Author  Topic 

misterzr
Starting Member

49 Posts

Posted - 2006-04-06 : 11:41:51
I have a table that I am trying to compare the value in one of the cells based on 2 different queries. I am looking for the lines that column COUNCS doesn't equal based on
Query 1
SELECT  *
FROM PRODDTA.F4105 INNER JOIN PRODDTA.F41021 ON LIITM = COITM AND LILOCN = COLOCN
WHERE LIPBIN ='P'
and COLEDG ='07'
AND LTRIM(COMCU) = 'MO'


Query 2
SELECT  *
FROM PRODDTA.F4105 INNER JOIN PRODDTA.F41021 ON LIITM = COITM AND LILOCN = COLOCN
WHERE LIPBIN ='P'
and COLEDG ='07'
AND LTRIM(COMCU) = 'UP'




nr
SQLTeam MVY

12543 Posts

Posted - 2006-04-06 : 12:05:46
Something like this. I'm guessing about the group by

SELECT t1.LIITM, t1.LILOCN, min(COUNCS), max(COUNCS)
FROM PRODDTA.F4105 t1 INNER JOIN PRODDTA.F41021 t2 ON LIITM = COITM AND LILOCN = COLOCN
WHERE LIPBIN ='P'
and COLEDG ='07'
and LTRIM(COMCU) in ('MO', 'UP')
group by t1.LIITM, t1.LILOCN
having count(distinct COUNCS) > 1

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

misterzr
Starting Member

49 Posts

Posted - 2006-04-06 : 13:02:36
Thanks NR, this looks like it works
Go to Top of Page
   

- Advertisement -