Buzzmeister14
Technical User
I have multiple tables in an SQL 2k DB
The problem lies in creating a view for this database that only contains required information, making it easier to create a report at a later date
There are three tables in question Client_Table, Policy_Table, Trade_LU
Client Table has a primary key of ClientId which is foreign in Policy_Table
Trade_LU has TradeId as Primary which is foreign in Client
I run the following SQL query
SELECT
Client."ClientId",
Client."Title",
Client."Forename",
Client."Surname",
Client."Company",
Client."Address1",
Client."Address2",
Client."Address3",
Client."Town",
Client."County",
Client."Postcode",
Client."Phone",
Client."Fax",
Client."Business_Description_VC",
Policy."Status",
Policy."EffectiveDate",
Trade_LU."Trade"
FROM
(ldu.dbo.Client Client INNER JOIN ldu.dbo.Policy Policy ON
Client."ClientId" = Policy."ClientId")
INNER JOIN ldu.dbo.Trade_LU Trade_LU ON
Client."TradeId" = Trade_LU."TradeId"
ORDER BY
Client."ClientId" ASC
However there are duplicate lines for client returned, because there are many policies for individual clients
However I would like no duplicates reported – so there would be one line for each Client – Have tried various distinct queries etc with no avail
Any help greatly appreciated
The problem lies in creating a view for this database that only contains required information, making it easier to create a report at a later date
There are three tables in question Client_Table, Policy_Table, Trade_LU
Client Table has a primary key of ClientId which is foreign in Policy_Table
Trade_LU has TradeId as Primary which is foreign in Client
I run the following SQL query
SELECT
Client."ClientId",
Client."Title",
Client."Forename",
Client."Surname",
Client."Company",
Client."Address1",
Client."Address2",
Client."Address3",
Client."Town",
Client."County",
Client."Postcode",
Client."Phone",
Client."Fax",
Client."Business_Description_VC",
Policy."Status",
Policy."EffectiveDate",
Trade_LU."Trade"
FROM
(ldu.dbo.Client Client INNER JOIN ldu.dbo.Policy Policy ON
Client."ClientId" = Policy."ClientId")
INNER JOIN ldu.dbo.Trade_LU Trade_LU ON
Client."TradeId" = Trade_LU."TradeId"
ORDER BY
Client."ClientId" ASC
However there are duplicate lines for client returned, because there are many policies for individual clients
However I would like no duplicates reported – so there would be one line for each Client – Have tried various distinct queries etc with no avail
Any help greatly appreciated