× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 11-Aug-2014 10:09 -0500, RPGLIST wrote:
I need to run a query (SQL) to find some records that are bad.

I need to find all freight movements with multiple stops that have a
temp flag that is different on the same Pro number. I can get the
first part:

Exec SQL Declare C1 Cursor For
Select CmlPro#, count(*) as cnt
from PBF1809
Where cmlShipDt > 20140101
and CmlShipDt < 20140901
group by CmlPro#
having count(*) > 1;

What I need to figure out is how to add in the same statement if
possible, where CmlTempFlg is different for any of those pro numbers?

Example:

Pro TempFlg
__________________
548798 32
548798 32
548798 58
548798 -5
...

All the records should have the same temp flg.

Suggestions?

The count of the DISTINCT values for the cmlTempFlg would not equate with one, if not all cmlTempFlg values were the same within the cmlPro# grouping. Thus I believe the following might satisfy the stated requirements?:

Select CmlPro#
, count(*) as cnt
, count(distinct cmlTempFlg) as dcnt
from PBF1809
Where cmlShipDt > 20140101
and CmlShipDt < 20140901
group by CmlPro#
having count(*) > 1
and count(distinct cmlTempFlg) <> 1


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.