How to find and remove duplicates in SQL Server
Described about my issue in IMAGE
I am using below joins to get certain data. I am getting 6 rows instead of 3. Can anyone help me out?
ALTER PROCEDURE [dbo].[psGetClientDropdownResult]
@lblCustomer VARCHAR(40),
@lblDeliveryplace VARCHAR(41),
@lblPackedProduct VARCHAR(41)
AS
BEGIN
SET NOCOUNT ON;
SELECT DISTINCT
Customer.lblCustomer As ClientDestinataire,
DeliveryPlace.lblDeliveryplace As LieuDeLivraison,
DeliveryPlace.codCountry AS Pays,
CustomerProduct.codCustomerProduct As CodeProduitClient,
CustomerProduct.codCustomerProductColor AS CodeCouleurClient,
CustomerProduct.codAqp AS AQP,
DeliveryPlace.codEMSupplier AS CodeFournisseurEMPourClient,
CustomerProduct.datApplication AS DateDApplication,
CustomerProduct.codPackedProduct AS Material,
Product.lblPProduct AS Produit,
Product.lblProduct AS RefFournisseur,
PackedProduct.lblPackedProduct AS MaterialDescription,
Packaging.nbrPackagingNetWeight AS PoidsNet,
(Packaging.nbrPackagingNetWeight) + (Packaging.nbrAddWeightFromNetToGross) AS PoidsBrut,
Customer.codCustomer as CodClient,
PackedProduct.codPackedProduct as Material,
Packaging.codPackaging as CodPackaging,
Packaging.nbrWeightCoefFromNetToGross as CoefNetBrut
FROM
Customer
INNER JOIN
CustomerProduct ON Customer.codCustomer = CustomerProduct.codCustomer
INNER JOIN
DeliveryPlace ON Customer.codCustomer = DeliveryPlace.codCustomer
INNER JOIN
PackedProduct ON CustomerProduct.codPackedProduct = PackedProduct.codPackedProduct
INNER JOIN
Product ON PackedProduct.codProduct = Product.codProduct
INNER JOIN
Packaging on Packaging.codPackaging = PackedProduct.codPackaging
WHERE
(Customer.lblCustomer = @lblCustomer or @lblCustomer IS NULL )
AND (DeliveryPlace.lblDeliveryplace = @lblDeliveryplace OR @lblDeliveryplace IS NULL)
AND (PackedProduct.lblPackedProduct = @lblPackedProduct OR @lblPackedProduct IS NULL)
I need help to understand how can i stop getting my records duplicates.
sql sql-server tsql
add a comment |
Described about my issue in IMAGE
I am using below joins to get certain data. I am getting 6 rows instead of 3. Can anyone help me out?
ALTER PROCEDURE [dbo].[psGetClientDropdownResult]
@lblCustomer VARCHAR(40),
@lblDeliveryplace VARCHAR(41),
@lblPackedProduct VARCHAR(41)
AS
BEGIN
SET NOCOUNT ON;
SELECT DISTINCT
Customer.lblCustomer As ClientDestinataire,
DeliveryPlace.lblDeliveryplace As LieuDeLivraison,
DeliveryPlace.codCountry AS Pays,
CustomerProduct.codCustomerProduct As CodeProduitClient,
CustomerProduct.codCustomerProductColor AS CodeCouleurClient,
CustomerProduct.codAqp AS AQP,
DeliveryPlace.codEMSupplier AS CodeFournisseurEMPourClient,
CustomerProduct.datApplication AS DateDApplication,
CustomerProduct.codPackedProduct AS Material,
Product.lblPProduct AS Produit,
Product.lblProduct AS RefFournisseur,
PackedProduct.lblPackedProduct AS MaterialDescription,
Packaging.nbrPackagingNetWeight AS PoidsNet,
(Packaging.nbrPackagingNetWeight) + (Packaging.nbrAddWeightFromNetToGross) AS PoidsBrut,
Customer.codCustomer as CodClient,
PackedProduct.codPackedProduct as Material,
Packaging.codPackaging as CodPackaging,
Packaging.nbrWeightCoefFromNetToGross as CoefNetBrut
FROM
Customer
INNER JOIN
CustomerProduct ON Customer.codCustomer = CustomerProduct.codCustomer
INNER JOIN
DeliveryPlace ON Customer.codCustomer = DeliveryPlace.codCustomer
INNER JOIN
PackedProduct ON CustomerProduct.codPackedProduct = PackedProduct.codPackedProduct
INNER JOIN
Product ON PackedProduct.codProduct = Product.codProduct
INNER JOIN
Packaging on Packaging.codPackaging = PackedProduct.codPackaging
WHERE
(Customer.lblCustomer = @lblCustomer or @lblCustomer IS NULL )
AND (DeliveryPlace.lblDeliveryplace = @lblDeliveryplace OR @lblDeliveryplace IS NULL)
AND (PackedProduct.lblPackedProduct = @lblPackedProduct OR @lblPackedProduct IS NULL)
I need help to understand how can i stop getting my records duplicates.
sql sql-server tsql
add a comment |
Described about my issue in IMAGE
I am using below joins to get certain data. I am getting 6 rows instead of 3. Can anyone help me out?
ALTER PROCEDURE [dbo].[psGetClientDropdownResult]
@lblCustomer VARCHAR(40),
@lblDeliveryplace VARCHAR(41),
@lblPackedProduct VARCHAR(41)
AS
BEGIN
SET NOCOUNT ON;
SELECT DISTINCT
Customer.lblCustomer As ClientDestinataire,
DeliveryPlace.lblDeliveryplace As LieuDeLivraison,
DeliveryPlace.codCountry AS Pays,
CustomerProduct.codCustomerProduct As CodeProduitClient,
CustomerProduct.codCustomerProductColor AS CodeCouleurClient,
CustomerProduct.codAqp AS AQP,
DeliveryPlace.codEMSupplier AS CodeFournisseurEMPourClient,
CustomerProduct.datApplication AS DateDApplication,
CustomerProduct.codPackedProduct AS Material,
Product.lblPProduct AS Produit,
Product.lblProduct AS RefFournisseur,
PackedProduct.lblPackedProduct AS MaterialDescription,
Packaging.nbrPackagingNetWeight AS PoidsNet,
(Packaging.nbrPackagingNetWeight) + (Packaging.nbrAddWeightFromNetToGross) AS PoidsBrut,
Customer.codCustomer as CodClient,
PackedProduct.codPackedProduct as Material,
Packaging.codPackaging as CodPackaging,
Packaging.nbrWeightCoefFromNetToGross as CoefNetBrut
FROM
Customer
INNER JOIN
CustomerProduct ON Customer.codCustomer = CustomerProduct.codCustomer
INNER JOIN
DeliveryPlace ON Customer.codCustomer = DeliveryPlace.codCustomer
INNER JOIN
PackedProduct ON CustomerProduct.codPackedProduct = PackedProduct.codPackedProduct
INNER JOIN
Product ON PackedProduct.codProduct = Product.codProduct
INNER JOIN
Packaging on Packaging.codPackaging = PackedProduct.codPackaging
WHERE
(Customer.lblCustomer = @lblCustomer or @lblCustomer IS NULL )
AND (DeliveryPlace.lblDeliveryplace = @lblDeliveryplace OR @lblDeliveryplace IS NULL)
AND (PackedProduct.lblPackedProduct = @lblPackedProduct OR @lblPackedProduct IS NULL)
I need help to understand how can i stop getting my records duplicates.
sql sql-server tsql
Described about my issue in IMAGE
I am using below joins to get certain data. I am getting 6 rows instead of 3. Can anyone help me out?
ALTER PROCEDURE [dbo].[psGetClientDropdownResult]
@lblCustomer VARCHAR(40),
@lblDeliveryplace VARCHAR(41),
@lblPackedProduct VARCHAR(41)
AS
BEGIN
SET NOCOUNT ON;
SELECT DISTINCT
Customer.lblCustomer As ClientDestinataire,
DeliveryPlace.lblDeliveryplace As LieuDeLivraison,
DeliveryPlace.codCountry AS Pays,
CustomerProduct.codCustomerProduct As CodeProduitClient,
CustomerProduct.codCustomerProductColor AS CodeCouleurClient,
CustomerProduct.codAqp AS AQP,
DeliveryPlace.codEMSupplier AS CodeFournisseurEMPourClient,
CustomerProduct.datApplication AS DateDApplication,
CustomerProduct.codPackedProduct AS Material,
Product.lblPProduct AS Produit,
Product.lblProduct AS RefFournisseur,
PackedProduct.lblPackedProduct AS MaterialDescription,
Packaging.nbrPackagingNetWeight AS PoidsNet,
(Packaging.nbrPackagingNetWeight) + (Packaging.nbrAddWeightFromNetToGross) AS PoidsBrut,
Customer.codCustomer as CodClient,
PackedProduct.codPackedProduct as Material,
Packaging.codPackaging as CodPackaging,
Packaging.nbrWeightCoefFromNetToGross as CoefNetBrut
FROM
Customer
INNER JOIN
CustomerProduct ON Customer.codCustomer = CustomerProduct.codCustomer
INNER JOIN
DeliveryPlace ON Customer.codCustomer = DeliveryPlace.codCustomer
INNER JOIN
PackedProduct ON CustomerProduct.codPackedProduct = PackedProduct.codPackedProduct
INNER JOIN
Product ON PackedProduct.codProduct = Product.codProduct
INNER JOIN
Packaging on Packaging.codPackaging = PackedProduct.codPackaging
WHERE
(Customer.lblCustomer = @lblCustomer or @lblCustomer IS NULL )
AND (DeliveryPlace.lblDeliveryplace = @lblDeliveryplace OR @lblDeliveryplace IS NULL)
AND (PackedProduct.lblPackedProduct = @lblPackedProduct OR @lblPackedProduct IS NULL)
I need help to understand how can i stop getting my records duplicates.
sql sql-server tsql
sql sql-server tsql
edited Nov 20 at 5:37
Rahul Neekhra
6021627
6021627
asked Nov 20 at 4:59
Naman
117
117
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Could you try this:
ALTER PROCEDURE [dbo].[psGetClientDropdownResult]
@lblCustomer VARCHAR(40),
@lblDeliveryplace VARCHAR(41),
@lblPackedProduct VARCHAR(41)
AS
BEGIN
SET NOCOUNT ON;
SELECT DISTINCT
Customer.lblCustomer As ClientDestinataire,
DeliveryPlace.lblDeliveryplace As LieuDeLivraison,
DeliveryPlace.codCountry AS Pays,
CustomerProduct.codCustomerProduct As CodeProduitClient,
CustomerProduct.codCustomerProductColor AS CodeCouleurClient,
CustomerProduct.codAqp AS AQP,
DeliveryPlace.codEMSupplier AS CodeFournisseurEMPourClient,
CustomerProduct.datApplication AS DateDApplication,
CustomerProduct.codPackedProduct AS Material,
Product.lblPProduct AS Produit,
Product.lblProduct AS RefFournisseur,
PackedProduct.lblPackedProduct AS MaterialDescription,
Packaging.nbrPackagingNetWeight AS PoidsNet,
(Packaging.nbrPackagingNetWeight) + (Packaging.nbrAddWeightFromNetToGross) AS PoidsBrut,
Customer.codCustomer as CodClient,
PackedProduct.codPackedProduct as Material,
Packaging.codPackaging as CodPackaging,
Packaging.nbrWeightCoefFromNetToGross as CoefNetBrut
FROM
Customer
INNER JOIN
CustomerProduct ON Customer.codCustomer = CustomerProduct.codCustomer
INNER JOIN
DeliveryPlace
ON Customer.codCustomer = DeliveryPlace.codCustomer
AND CustomerProduct.lblDeliveryplace = DeliveryPlace.lblDeliveryplace
INNER JOIN
PackedProduct ON CustomerProduct.codPackedProduct = PackedProduct.codPackedProduct
INNER JOIN
Product ON PackedProduct.codProduct = Product.codProduct
INNER JOIN
Packaging on Packaging.codPackaging = PackedProduct.codPackaging
WHERE
(Customer.lblCustomer = @lblCustomer or @lblCustomer IS NULL )
AND (DeliveryPlace.lblDeliveryplace = @lblDeliveryplace OR @lblDeliveryplace IS NULL)
AND (PackedProduct.lblPackedProduct = @lblPackedProduct OR @lblPackedProduct IS NULL)
The DeliveryPlace
must be join using codCustomer
and lblDeliveryplace
or you will get more rows then needed.
It will be better if you can normalized your data and move the address in separate table. Then you will be able to join the data using integer
column for example.
Its working as expected.
– Naman
Nov 20 at 5:56
@Naman Does this help?
– gotqn
Nov 20 at 6:22
@Naman If the answer is working and as expected please click tick mark near answer and make it green
– Santhana
Nov 20 at 7:00
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386495%2fhow-to-find-and-remove-duplicates-in-sql-server%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Could you try this:
ALTER PROCEDURE [dbo].[psGetClientDropdownResult]
@lblCustomer VARCHAR(40),
@lblDeliveryplace VARCHAR(41),
@lblPackedProduct VARCHAR(41)
AS
BEGIN
SET NOCOUNT ON;
SELECT DISTINCT
Customer.lblCustomer As ClientDestinataire,
DeliveryPlace.lblDeliveryplace As LieuDeLivraison,
DeliveryPlace.codCountry AS Pays,
CustomerProduct.codCustomerProduct As CodeProduitClient,
CustomerProduct.codCustomerProductColor AS CodeCouleurClient,
CustomerProduct.codAqp AS AQP,
DeliveryPlace.codEMSupplier AS CodeFournisseurEMPourClient,
CustomerProduct.datApplication AS DateDApplication,
CustomerProduct.codPackedProduct AS Material,
Product.lblPProduct AS Produit,
Product.lblProduct AS RefFournisseur,
PackedProduct.lblPackedProduct AS MaterialDescription,
Packaging.nbrPackagingNetWeight AS PoidsNet,
(Packaging.nbrPackagingNetWeight) + (Packaging.nbrAddWeightFromNetToGross) AS PoidsBrut,
Customer.codCustomer as CodClient,
PackedProduct.codPackedProduct as Material,
Packaging.codPackaging as CodPackaging,
Packaging.nbrWeightCoefFromNetToGross as CoefNetBrut
FROM
Customer
INNER JOIN
CustomerProduct ON Customer.codCustomer = CustomerProduct.codCustomer
INNER JOIN
DeliveryPlace
ON Customer.codCustomer = DeliveryPlace.codCustomer
AND CustomerProduct.lblDeliveryplace = DeliveryPlace.lblDeliveryplace
INNER JOIN
PackedProduct ON CustomerProduct.codPackedProduct = PackedProduct.codPackedProduct
INNER JOIN
Product ON PackedProduct.codProduct = Product.codProduct
INNER JOIN
Packaging on Packaging.codPackaging = PackedProduct.codPackaging
WHERE
(Customer.lblCustomer = @lblCustomer or @lblCustomer IS NULL )
AND (DeliveryPlace.lblDeliveryplace = @lblDeliveryplace OR @lblDeliveryplace IS NULL)
AND (PackedProduct.lblPackedProduct = @lblPackedProduct OR @lblPackedProduct IS NULL)
The DeliveryPlace
must be join using codCustomer
and lblDeliveryplace
or you will get more rows then needed.
It will be better if you can normalized your data and move the address in separate table. Then you will be able to join the data using integer
column for example.
Its working as expected.
– Naman
Nov 20 at 5:56
@Naman Does this help?
– gotqn
Nov 20 at 6:22
@Naman If the answer is working and as expected please click tick mark near answer and make it green
– Santhana
Nov 20 at 7:00
add a comment |
Could you try this:
ALTER PROCEDURE [dbo].[psGetClientDropdownResult]
@lblCustomer VARCHAR(40),
@lblDeliveryplace VARCHAR(41),
@lblPackedProduct VARCHAR(41)
AS
BEGIN
SET NOCOUNT ON;
SELECT DISTINCT
Customer.lblCustomer As ClientDestinataire,
DeliveryPlace.lblDeliveryplace As LieuDeLivraison,
DeliveryPlace.codCountry AS Pays,
CustomerProduct.codCustomerProduct As CodeProduitClient,
CustomerProduct.codCustomerProductColor AS CodeCouleurClient,
CustomerProduct.codAqp AS AQP,
DeliveryPlace.codEMSupplier AS CodeFournisseurEMPourClient,
CustomerProduct.datApplication AS DateDApplication,
CustomerProduct.codPackedProduct AS Material,
Product.lblPProduct AS Produit,
Product.lblProduct AS RefFournisseur,
PackedProduct.lblPackedProduct AS MaterialDescription,
Packaging.nbrPackagingNetWeight AS PoidsNet,
(Packaging.nbrPackagingNetWeight) + (Packaging.nbrAddWeightFromNetToGross) AS PoidsBrut,
Customer.codCustomer as CodClient,
PackedProduct.codPackedProduct as Material,
Packaging.codPackaging as CodPackaging,
Packaging.nbrWeightCoefFromNetToGross as CoefNetBrut
FROM
Customer
INNER JOIN
CustomerProduct ON Customer.codCustomer = CustomerProduct.codCustomer
INNER JOIN
DeliveryPlace
ON Customer.codCustomer = DeliveryPlace.codCustomer
AND CustomerProduct.lblDeliveryplace = DeliveryPlace.lblDeliveryplace
INNER JOIN
PackedProduct ON CustomerProduct.codPackedProduct = PackedProduct.codPackedProduct
INNER JOIN
Product ON PackedProduct.codProduct = Product.codProduct
INNER JOIN
Packaging on Packaging.codPackaging = PackedProduct.codPackaging
WHERE
(Customer.lblCustomer = @lblCustomer or @lblCustomer IS NULL )
AND (DeliveryPlace.lblDeliveryplace = @lblDeliveryplace OR @lblDeliveryplace IS NULL)
AND (PackedProduct.lblPackedProduct = @lblPackedProduct OR @lblPackedProduct IS NULL)
The DeliveryPlace
must be join using codCustomer
and lblDeliveryplace
or you will get more rows then needed.
It will be better if you can normalized your data and move the address in separate table. Then you will be able to join the data using integer
column for example.
Its working as expected.
– Naman
Nov 20 at 5:56
@Naman Does this help?
– gotqn
Nov 20 at 6:22
@Naman If the answer is working and as expected please click tick mark near answer and make it green
– Santhana
Nov 20 at 7:00
add a comment |
Could you try this:
ALTER PROCEDURE [dbo].[psGetClientDropdownResult]
@lblCustomer VARCHAR(40),
@lblDeliveryplace VARCHAR(41),
@lblPackedProduct VARCHAR(41)
AS
BEGIN
SET NOCOUNT ON;
SELECT DISTINCT
Customer.lblCustomer As ClientDestinataire,
DeliveryPlace.lblDeliveryplace As LieuDeLivraison,
DeliveryPlace.codCountry AS Pays,
CustomerProduct.codCustomerProduct As CodeProduitClient,
CustomerProduct.codCustomerProductColor AS CodeCouleurClient,
CustomerProduct.codAqp AS AQP,
DeliveryPlace.codEMSupplier AS CodeFournisseurEMPourClient,
CustomerProduct.datApplication AS DateDApplication,
CustomerProduct.codPackedProduct AS Material,
Product.lblPProduct AS Produit,
Product.lblProduct AS RefFournisseur,
PackedProduct.lblPackedProduct AS MaterialDescription,
Packaging.nbrPackagingNetWeight AS PoidsNet,
(Packaging.nbrPackagingNetWeight) + (Packaging.nbrAddWeightFromNetToGross) AS PoidsBrut,
Customer.codCustomer as CodClient,
PackedProduct.codPackedProduct as Material,
Packaging.codPackaging as CodPackaging,
Packaging.nbrWeightCoefFromNetToGross as CoefNetBrut
FROM
Customer
INNER JOIN
CustomerProduct ON Customer.codCustomer = CustomerProduct.codCustomer
INNER JOIN
DeliveryPlace
ON Customer.codCustomer = DeliveryPlace.codCustomer
AND CustomerProduct.lblDeliveryplace = DeliveryPlace.lblDeliveryplace
INNER JOIN
PackedProduct ON CustomerProduct.codPackedProduct = PackedProduct.codPackedProduct
INNER JOIN
Product ON PackedProduct.codProduct = Product.codProduct
INNER JOIN
Packaging on Packaging.codPackaging = PackedProduct.codPackaging
WHERE
(Customer.lblCustomer = @lblCustomer or @lblCustomer IS NULL )
AND (DeliveryPlace.lblDeliveryplace = @lblDeliveryplace OR @lblDeliveryplace IS NULL)
AND (PackedProduct.lblPackedProduct = @lblPackedProduct OR @lblPackedProduct IS NULL)
The DeliveryPlace
must be join using codCustomer
and lblDeliveryplace
or you will get more rows then needed.
It will be better if you can normalized your data and move the address in separate table. Then you will be able to join the data using integer
column for example.
Could you try this:
ALTER PROCEDURE [dbo].[psGetClientDropdownResult]
@lblCustomer VARCHAR(40),
@lblDeliveryplace VARCHAR(41),
@lblPackedProduct VARCHAR(41)
AS
BEGIN
SET NOCOUNT ON;
SELECT DISTINCT
Customer.lblCustomer As ClientDestinataire,
DeliveryPlace.lblDeliveryplace As LieuDeLivraison,
DeliveryPlace.codCountry AS Pays,
CustomerProduct.codCustomerProduct As CodeProduitClient,
CustomerProduct.codCustomerProductColor AS CodeCouleurClient,
CustomerProduct.codAqp AS AQP,
DeliveryPlace.codEMSupplier AS CodeFournisseurEMPourClient,
CustomerProduct.datApplication AS DateDApplication,
CustomerProduct.codPackedProduct AS Material,
Product.lblPProduct AS Produit,
Product.lblProduct AS RefFournisseur,
PackedProduct.lblPackedProduct AS MaterialDescription,
Packaging.nbrPackagingNetWeight AS PoidsNet,
(Packaging.nbrPackagingNetWeight) + (Packaging.nbrAddWeightFromNetToGross) AS PoidsBrut,
Customer.codCustomer as CodClient,
PackedProduct.codPackedProduct as Material,
Packaging.codPackaging as CodPackaging,
Packaging.nbrWeightCoefFromNetToGross as CoefNetBrut
FROM
Customer
INNER JOIN
CustomerProduct ON Customer.codCustomer = CustomerProduct.codCustomer
INNER JOIN
DeliveryPlace
ON Customer.codCustomer = DeliveryPlace.codCustomer
AND CustomerProduct.lblDeliveryplace = DeliveryPlace.lblDeliveryplace
INNER JOIN
PackedProduct ON CustomerProduct.codPackedProduct = PackedProduct.codPackedProduct
INNER JOIN
Product ON PackedProduct.codProduct = Product.codProduct
INNER JOIN
Packaging on Packaging.codPackaging = PackedProduct.codPackaging
WHERE
(Customer.lblCustomer = @lblCustomer or @lblCustomer IS NULL )
AND (DeliveryPlace.lblDeliveryplace = @lblDeliveryplace OR @lblDeliveryplace IS NULL)
AND (PackedProduct.lblPackedProduct = @lblPackedProduct OR @lblPackedProduct IS NULL)
The DeliveryPlace
must be join using codCustomer
and lblDeliveryplace
or you will get more rows then needed.
It will be better if you can normalized your data and move the address in separate table. Then you will be able to join the data using integer
column for example.
answered Nov 20 at 5:47
gotqn
19.6k32111189
19.6k32111189
Its working as expected.
– Naman
Nov 20 at 5:56
@Naman Does this help?
– gotqn
Nov 20 at 6:22
@Naman If the answer is working and as expected please click tick mark near answer and make it green
– Santhana
Nov 20 at 7:00
add a comment |
Its working as expected.
– Naman
Nov 20 at 5:56
@Naman Does this help?
– gotqn
Nov 20 at 6:22
@Naman If the answer is working and as expected please click tick mark near answer and make it green
– Santhana
Nov 20 at 7:00
Its working as expected.
– Naman
Nov 20 at 5:56
Its working as expected.
– Naman
Nov 20 at 5:56
@Naman Does this help?
– gotqn
Nov 20 at 6:22
@Naman Does this help?
– gotqn
Nov 20 at 6:22
@Naman If the answer is working and as expected please click tick mark near answer and make it green
– Santhana
Nov 20 at 7:00
@Naman If the answer is working and as expected please click tick mark near answer and make it green
– Santhana
Nov 20 at 7:00
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386495%2fhow-to-find-and-remove-duplicates-in-sql-server%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown