
Anonymous
Not applicable
2013-10-16
09:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[resolved] How to count distinct values in a lot of columns in SQL server
Hello,
I have to count distinct values in a (SQL server) table containing about 100 columns.
I know how to retrieve the schema of the table (with a TMSSQLColumnList) but i don't know how to loop on the columns names.
Can somebody help me ?
Thanks for your help.
(sorry for my bad English)
I have to count distinct values in a (SQL server) table containing about 100 columns.
I know how to retrieve the schema of the table (with a TMSSQLColumnList) but i don't know how to loop on the columns names.
Can somebody help me ?
Thanks for your help.
(sorry for my bad English)
395 Views
1 Solution
Accepted Solutions

Anonymous
Not applicable
2013-10-28
11:57 PM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think you will need to loop through the column names with a dynamic string.
You can try the following approach
tMSSQLInput_1 (with 1 column as colName) ---> main (row1) ---> tFlowToIterate ---> Iterate ---> tMSSQLInput_2 ---> t_UniqRow
In tMSSQLInput_1 use the below statement:
"SELECT column
FROM syscolumns
WHERE id=OBJECT_ID('YOUR_TABLE') "
In tMSSQLInput_2 use the below statement:
"select " + ((Integer)globalMap.get("row1.ColName")) + " from tablename"
Sorry I recently switched to Oracle so can't show you a working example.
Hope this helps.
G.
You can try the following approach
tMSSQLInput_1 (with 1 column as colName) ---> main (row1) ---> tFlowToIterate ---> Iterate ---> tMSSQLInput_2 ---> t_UniqRow
In tMSSQLInput_1 use the below statement:
"SELECT column
FROM syscolumns
WHERE id=OBJECT_ID('YOUR_TABLE') "
In tMSSQLInput_2 use the below statement:
"select " + ((Integer)globalMap.get("row1.ColName")) + " from tablename"
Sorry I recently switched to Oracle so can't show you a working example.
Hope this helps.
G.
395 Views
4 Replies

Anonymous
Not applicable
2013-10-17
12:47 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
It seems you need use SQL query to achieve that.
Please refer to the article http://stackoverflow.com/questions/16497761/how-to-count-distinct-column-in-sql-server to see if it is what you need.
Best regards
Sabrina
It seems you need use SQL query to achieve that.
Please refer to the article http://stackoverflow.com/questions/16497761/how-to-count-distinct-column-in-sql-server to see if it is what you need.
Best regards
Sabrina
395 Views

Anonymous
Not applicable
2013-10-17
05:00 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello xdshi (and all of you),
Thank's for your answer, the problem I encounter is the fact that I don't manage to link the file which contains the names of the columns with the SQL request.
I would like to do a request like that :
SELECT columnname,COUNT(columnname) FROM myTable
GROUP by columnname
I want to iterate this request for each column of my table.
I think it's impossible to do it with a Taggregaterow.
I hope you understand better my problem.
Thanks.
Thank's for your answer, the problem I encounter is the fact that I don't manage to link the file which contains the names of the columns with the SQL request.
I would like to do a request like that :
SELECT columnname,COUNT(columnname) FROM myTable
GROUP by columnname
I want to iterate this request for each column of my table.
I think it's impossible to do it with a Taggregaterow.
I hope you understand better my problem.
Thanks.
395 Views

Anonymous
Not applicable
2013-10-28
11:57 PM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think you will need to loop through the column names with a dynamic string.
You can try the following approach
tMSSQLInput_1 (with 1 column as colName) ---> main (row1) ---> tFlowToIterate ---> Iterate ---> tMSSQLInput_2 ---> t_UniqRow
In tMSSQLInput_1 use the below statement:
"SELECT column
FROM syscolumns
WHERE id=OBJECT_ID('YOUR_TABLE') "
In tMSSQLInput_2 use the below statement:
"select " + ((Integer)globalMap.get("row1.ColName")) + " from tablename"
Sorry I recently switched to Oracle so can't show you a working example.
Hope this helps.
G.
You can try the following approach
tMSSQLInput_1 (with 1 column as colName) ---> main (row1) ---> tFlowToIterate ---> Iterate ---> tMSSQLInput_2 ---> t_UniqRow
In tMSSQLInput_1 use the below statement:
"SELECT column
FROM syscolumns
WHERE id=OBJECT_ID('YOUR_TABLE') "
In tMSSQLInput_2 use the below statement:
"select " + ((Integer)globalMap.get("row1.ColName")) + " from tablename"
Sorry I recently switched to Oracle so can't show you a working example.
Hope this helps.
G.
396 Views

Anonymous
Not applicable
2013-10-30
05:50 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Thanks a lot G. for your help, it's working with your explanation.
Best regards.
TD
Thanks a lot G. for your help, it's working with your explanation.
Best regards.
TD
395 Views
