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 |
cplusplus
Aged Yak Warrior
567 Posts |
Posted - 2013-01-24 : 10:02:38
|
How to check duplicate rows based on these columns: 259k rows are in teh table.Is it possible to see a count based on teh combination of all fields, to se how many rows are there.select table_name, active, businessunitid, cost_center, glacct, glsubacct from LAW_DEL_IMGNOW_GLACCT_CHG; Thank you very much for the helpful info. |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-01-24 : 11:11:31
|
You can use the row_number function or group by clause - in the example below, I am using group by. If you want to see only rows that have duplicates, uncomment the last lineselect table_name, active, businessunitid, cost_center, glacct, glsubacct, COUNT(*) AS DupCount from LAW_DEL_IMGNOW_GLACCT_CHGGROUP BY select table_name, active, businessunitid, cost_center, glacct, glsubacct from LAW_DEL_IMGNOW_GLACCT_CHG-- HAVING COUNT(*) > 1 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-01-25 : 01:35:50
|
quote: Originally posted by James K You can use the row_number function or group by clause - in the example below, I am using group by. If you want to see only rows that have duplicates, uncomment the last lineselect table_name, active, businessunitid, cost_center, glacct, glsubacct, COUNT(*) AS DupCount from LAW_DEL_IMGNOW_GLACCT_CHGGROUP BY select table_name, active, businessunitid, cost_center, glacct, glsubacct from LAW_DEL_IMGNOW_GLACCT_CHG-- HAVING COUNT(*) > 1
fixed typos------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-01-25 : 07:59:51
|
How embarrassing! Thank you Visakh. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-01-25 : 09:45:14
|
No problem..It happens to all ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|
|
|