SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Data Profilng Column Functional Dependency T-SQL


Data Profilng Column Functional Dependency T-SQL

Author
Message
Ira Warren Whiteside
Ira Warren Whiteside
SSC-Enthusiastic
SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)

Group: General Forum Members
Points: 198 Visits: 296
Comments posted to this topic are about the item Data Profilng Column Functional Dependency T-SQL

Ira Warren Whiteside
tomasz.cwajda
tomasz.cwajda
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 31
I really don't know what is showig this pie chart !

This is some creasy idea to use pie chart to this data, is't it?
tomasz.cwajda
tomasz.cwajda
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 31
I don't know why you make it in so complikated way.

Below you can find my version of your procedure.

CREATE PROCEDURE [dbo].[ColumnDependency2]
@TableName VARCHAR(128) ,
@Determinant VARCHAR(128) ,
@Dependent VARCHAR(128)

AS
Declare @SQL VarChar(MAX);
SELECT @SQL = 'WITH all_ AS (
SELECT '+@Determinant+'
,'+@Dependent+'
,count(*) cnt
FROM '+@TableName+'
GROUP BY '+@Determinant+'
,'+@Dependent+'
)
, fraction_ AS (
SELECT '+@Determinant+'
,max(cnt) support_count
,sum(cnt) frac_cnt
FROM all_
GROUP BY '+@Determinant+'
)
SELECT v.'+@Determinant+'
,'+@Dependent+'
,cnt [Dependeny Counts]
,case when cnt < support_count then ''Violation Percentage''
ELSE ''Support Percentage''
end [Dependency type]
,CAST(CAST(cnt AS DECIMAL ) / frac_cnt * 100 AS DECIMAL (5, 2)) AS PercentViolation
FROM all_ v
,fraction_
WHERE fraction_.'+@Determinant+' = v.'+@Determinant+'
ORDER BY 1, 3 DESC ';
Print @SQL
Exec (@SQL)



and execution:

Exec ColumnDependency2
@TableName = 'Addresses',
@Dependent = 'StateProvinceName',
@Determinant = 'CountryRegionCode '



Wink
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search