count of distinct
Teradata Teradata Discussion Forums Teradata.com Discussion Forum
Visit Teradata.com
Home       Guidelines    Member List
Welcome Guest ( Login | Register )
        


This online forum is for user-to-user discussions of Teradata products, and is not an official customer support channel for Teradata. If you require direct assistance, please contact Teradata support.


count of distinct Expand / Collapse
Author
Message
Posted 7/6/2006 6:53:32 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 7/3/2008 3:49:29 AM
Posts: 22, Visits: 21
How to get the count(combination of distinct values of two columns together).

i am giving the query in the following way

select count(distinct INVENTORY_ITEM_KEY,COST_TYPE_KEY) from ITEM_COST_DETAILS_F

but it is giving error at INVENTORY_ITEM_KEY and ','


dixon
Post #4526
Posted 7/6/2006 7:46:17 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 6/9/2008 2:55:55 PM
Posts: 185, Visits: 2
You can concatenate the columns together:

select count(distinct INVENTORY_ITEM_KEY || COST_TYPE_KEY) from ITEM_COST_DETAILS_F

Be 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.
Post #4528
Posted 7/6/2006 7:53:30 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 8/2/2006 4:09:00 PM
Posts: 19, Visits: 1
If the text conversion causes issues, you may want to try a GROUP BY of INVENTORY_ITEM_KEY,COST_TYPE_KEY instead of concatenating.
Post #4529
Posted 7/11/2006 10:58:12 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 9/11/2007 7:46:00 AM
Posts: 4, Visits: 1
have you try this :
select count(*) from
select INVENTORY_ITEM_KEY,COST_TYPE_KEY
from ITEM_COST_DETAILS_F
group by INVENTORY_ITEM_KEY,COST_TYPE_KEY ) as MYCOUNT

Post #4570
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 ( 0 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.


All times are GMT -5:00, Time now is 12:05pm

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.063. 9 queries. Compression Disabled.