Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
helpwithSQL1502
Starting Member
1 Post |
Posted - 2013-07-24 : 23:26:37
|
Hi everyone. I have a table in Access 2007 that has about 30 field names and I want to have a count of how many unique rows there are in each field. I want to have these results put into another table that will just have the field name and then the count of how many unique rows there are.I have code in VBA that will loop through my SQL and change out the field name, but I can't seem to get the SQL right before I can start looping it. For just one field name this would be what I have to count the unique names...So far I have this:INSERT INTO newtableCOUNT(*) FROM (SELECT Raw_Table.FieldName, COUNT(Raw_Table.FieldName) AS CountOfFieldNameFROM Raw_TableGROUP BY Raw_Table.FieldName);And its not going too well.If any of you SQL gurus could fix this problem for a novice like myself, it would really be a big help. Thanks in advance. |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-07-25 : 00:31:19
|
-- You mean to have number of different values in the column. Then Query should be as follws: SELECT COUNT(DISTINCT Raw_Table.FieldName)FROM Raw_Table--Chandu |
|
|
|
|
|