Feeds:
Posts
Comments

Archive for September, 2010

count distinct

To know whether one external_item_key could have more than one subvendorid:

select external_item_key, count(distinct subvendorid)  from dbo.ETL_BULKINSERT_TARGET_HISTORY_POWERSHELL group by external_item_key;

select distinct count(distinct subvendorid)  from dbo.ETL_BULKINSERT_TARGET_HISTORY_POWERSHELL group by external_item_key;

Advertisements

Read Full Post »

$a='aa','aa1','aa2','bb','bb1','bb2'
$hashT=@{}

foreach ($i in $a)
{
 $re= $i -match '^(..)'
 $type=$matches[1]
 if (!$hashT.ContainsKey($type)){
      $hashT[$type]=@()  ##********   this is the key to treat the element as an array, otherwise it treats it like string
    }
  $hashT[$type]=$hashT[$type]+$i
 }

foreach ($i in $hashT['aa']){
   $i
 }

 foreach ($i in $hashT['bb']){
   $i
 }

Read Full Post »