SQL Server 2008 Modified WHERE Statement -
my sql server 2008 table constructed follows: 160 columns consisting of ratio_id , 160 companies headers 742 rows consisting of ratio_id's per company.
the typical structure be:
ratio_id | company 1 | company 2 | company 160
part03x0 | 0.01 | 0.03 | ratio_id742 |
how able run query request companies ratio_id part03x0 zero?
tried google this, explaining difficult.
hope makes sense!
why storing companies columns? companies should placed in own table, unique id referring each company. can use id ratio_id in order perform query.
160 columns massive overkill. here nice tutorial on how normalize database.
edit:
you not need have table each company. need 1 table named, example, tbl_company , add following:
company_id | company_name 1 | companynameone 2 | companynametwo 3 | companynamethree
another table ratios, tbl_ratio
ratio_id | ratio_name 1 | rationameone 2 | rationametwo
then combine both using foreignkeys
, relationships
between 2 tables separate table below:
tbl_company_ratio
company_id | ratio_id | ratio_amount 1 2 5 1 1 2 3 2 10 2 2 5 ....
Comments
Post a Comment