All Forums Analytics
dixon 22 posts Joined 01/06
06 Jul 2006
count of distinct

How to get the count(combination of distinct values of two columns together). i am giving the query in the following wayselect count(distinct INVENTORY_ITEM_KEY,COST_TYPE_KEY) from ITEM_COST_DETAILS_Fbut it is giving error at INVENTORY_ITEM_KEY and ','

Barry-1604 176 posts Joined 07/05
06 Jul 2006

You can concatenate the columns together:select count(distinct INVENTORY_ITEM_KEY || COST_TYPE_KEY) from ITEM_COST_DETAILS_FBe aware that this will convert both columns to a CHARACTER data type before concatenating them, so you'll want to make sure the format of the column will properly report all values.Hope that helps.

kathyk 3 posts Joined 07/04
06 Jul 2006

If the text conversion causes issues, you may want to try a GROUP BY of INVENTORY_ITEM_KEY,COST_TYPE_KEY instead of concatenating.

zebulon 2 posts Joined 12/05
11 Jul 2006

have you try this :select count(*) from select INVENTORY_ITEM_KEY,COST_TYPE_KEYfrom ITEM_COST_DETAILS_Fgroup by INVENTORY_ITEM_KEY,COST_TYPE_KEY ) as MYCOUNT

You must sign in to leave a comment.