B
Brad
Thanks for taking the time to read my question.
I'm updating a DB and currently all the prices are split into different
columns based on package size. I'd like to get all prices into one column
now, as each package size now has it's own product code (Before there was
only one code regardless of package size).
What I've tried is a UNION SELECT query putting all the prices under one
column. What I'm getting is double the records. One record has a price, the
duplicate doesn't. I've put my SQL below.
How do I get rid of the duplicate record?
Thanks,
Brad
SQL:
SELECT DISTINCTROW qry_MillPricing.Facility, qry_MillPricing.Group,
qry_MillPricing.number, qry_MillPricing.productcode, qry_MillPricing.CustNum,
qry_MillPricing.Description, qry_MillPricing.species,
qry_MillPricing.subspecies, qry_MillPricing.texture, qry_MillPricing.Mill,
qry_MillPricing.TotePrice AS Price, qry_MillPricing.SellingUofM_XX,
qry_MillPricing.IUMRC_XX, qry_MillPricing.BCHLD_XX
FROM qry_MillPricing
UNION SELECT DISTINCTROW qry_MillPricing.Facility, qry_MillPricing.Group,
qry_MillPricing.number, qry_MillPricing.productcode, qry_MillPricing.CustNum,
qry_MillPricing.Description, qry_MillPricing.species,
qry_MillPricing.subspecies, qry_MillPricing.texture, qry_MillPricing.Mill,
qry_MillPricing.[25KGBagPrice], qry_MillPricing.SellingUofM_XX,
qry_MillPricing.IUMRC_XX, qry_MillPricing.BCHLD_XX
FROM qry_MillPricing
UNION SELECT DISTINCTROW qry_MillPricing.Facility, qry_MillPricing.Group,
qry_MillPricing.number, qry_MillPricing.productcode, qry_MillPricing.CustNum,
qry_MillPricing.Description, qry_MillPricing.species,
qry_MillPricing.subspecies, qry_MillPricing.texture, qry_MillPricing.Mill,
qry_MillPricing.BulkPrice, qry_MillPricing.SellingUofM_XX,
qry_MillPricing.IUMRC_XX, qry_MillPricing.BCHLD_XX
FROM qry_MillPricing
UNION SELECT DISTINCTROW qry_MillPricing.Facility, qry_MillPricing.Group,
qry_MillPricing.number, qry_MillPricing.productcode, qry_MillPricing.CustNum,
qry_MillPricing.Description, qry_MillPricing.species,
qry_MillPricing.subspecies, qry_MillPricing.texture, qry_MillPricing.Mill,
qry_MillPricing.EachPrice, qry_MillPricing.SellingUofM_XX,
qry_MillPricing.IUMRC_XX, qry_MillPricing.BCHLD_XX
FROM qry_MillPricing
UNION SELECT DISTINCTROW qry_MillPricing.Facility, qry_MillPricing.Group,
qry_MillPricing.number, qry_MillPricing.productcode, qry_MillPricing.CustNum,
qry_MillPricing.Description, qry_MillPricing.species,
qry_MillPricing.subspecies, qry_MillPricing.texture, qry_MillPricing.Mill,
qry_MillPricing.[10KGBagPrice], qry_MillPricing.SellingUofM_XX,
qry_MillPricing.IUMRC_XX, qry_MillPricing.BCHLD_XX
FROM qry_MillPricing
UNION SELECT DISTINCTROW qry_MillPricing.Facility, qry_MillPricing.Group,
qry_MillPricing.number, qry_MillPricing.productcode, qry_MillPricing.CustNum,
qry_MillPricing.Description, qry_MillPricing.species,
qry_MillPricing.subspecies, qry_MillPricing.texture, qry_MillPricing.Mill,
qry_MillPricing.[20KGBagPrice], qry_MillPricing.SellingUofM_XX,
qry_MillPricing.IUMRC_XX, qry_MillPricing.BCHLD_XX
FROM qry_MillPricing
UNION SELECT DISTINCTROW qry_MillPricing.Facility, qry_MillPricing.Group,
qry_MillPricing.number, qry_MillPricing.productcode, qry_MillPricing.CustNum,
qry_MillPricing.Description, qry_MillPricing.species,
qry_MillPricing.subspecies, qry_MillPricing.texture, qry_MillPricing.Mill,
qry_MillPricing.[30KGBagPrice], qry_MillPricing.SellingUofM_XX,
qry_MillPricing.IUMRC_XX, qry_MillPricing.BCHLD_XX
FROM qry_MillPricing
UNION SELECT DISTINCTROW qry_MillPricing.Facility, qry_MillPricing.Group,
qry_MillPricing.number, qry_MillPricing.productcode, qry_MillPricing.CustNum,
qry_MillPricing.Description, qry_MillPricing.species,
qry_MillPricing.subspecies, qry_MillPricing.texture, qry_MillPricing.Mill,
qry_MillPricing.[227KGBagPrice], qry_MillPricing.SellingUofM_XX,
qry_MillPricing.IUMRC_XX, qry_MillPricing.BCHLD_XX
FROM qry_MillPricing
UNION SELECT DISTINCTROW qry_MillPricing.Facility, qry_MillPricing.Group,
qry_MillPricing.number, qry_MillPricing.productcode, qry_MillPricing.CustNum,
qry_MillPricing.Description, qry_MillPricing.species,
qry_MillPricing.subspecies, qry_MillPricing.texture, qry_MillPricing.Mill,
qry_MillPricing.PerKGPrice, qry_MillPricing.SellingUofM_XX,
qry_MillPricing.IUMRC_XX, qry_MillPricing.BCHLD_XX
FROM qry_MillPricing;
I'm updating a DB and currently all the prices are split into different
columns based on package size. I'd like to get all prices into one column
now, as each package size now has it's own product code (Before there was
only one code regardless of package size).
What I've tried is a UNION SELECT query putting all the prices under one
column. What I'm getting is double the records. One record has a price, the
duplicate doesn't. I've put my SQL below.
How do I get rid of the duplicate record?
Thanks,
Brad
SQL:
SELECT DISTINCTROW qry_MillPricing.Facility, qry_MillPricing.Group,
qry_MillPricing.number, qry_MillPricing.productcode, qry_MillPricing.CustNum,
qry_MillPricing.Description, qry_MillPricing.species,
qry_MillPricing.subspecies, qry_MillPricing.texture, qry_MillPricing.Mill,
qry_MillPricing.TotePrice AS Price, qry_MillPricing.SellingUofM_XX,
qry_MillPricing.IUMRC_XX, qry_MillPricing.BCHLD_XX
FROM qry_MillPricing
UNION SELECT DISTINCTROW qry_MillPricing.Facility, qry_MillPricing.Group,
qry_MillPricing.number, qry_MillPricing.productcode, qry_MillPricing.CustNum,
qry_MillPricing.Description, qry_MillPricing.species,
qry_MillPricing.subspecies, qry_MillPricing.texture, qry_MillPricing.Mill,
qry_MillPricing.[25KGBagPrice], qry_MillPricing.SellingUofM_XX,
qry_MillPricing.IUMRC_XX, qry_MillPricing.BCHLD_XX
FROM qry_MillPricing
UNION SELECT DISTINCTROW qry_MillPricing.Facility, qry_MillPricing.Group,
qry_MillPricing.number, qry_MillPricing.productcode, qry_MillPricing.CustNum,
qry_MillPricing.Description, qry_MillPricing.species,
qry_MillPricing.subspecies, qry_MillPricing.texture, qry_MillPricing.Mill,
qry_MillPricing.BulkPrice, qry_MillPricing.SellingUofM_XX,
qry_MillPricing.IUMRC_XX, qry_MillPricing.BCHLD_XX
FROM qry_MillPricing
UNION SELECT DISTINCTROW qry_MillPricing.Facility, qry_MillPricing.Group,
qry_MillPricing.number, qry_MillPricing.productcode, qry_MillPricing.CustNum,
qry_MillPricing.Description, qry_MillPricing.species,
qry_MillPricing.subspecies, qry_MillPricing.texture, qry_MillPricing.Mill,
qry_MillPricing.EachPrice, qry_MillPricing.SellingUofM_XX,
qry_MillPricing.IUMRC_XX, qry_MillPricing.BCHLD_XX
FROM qry_MillPricing
UNION SELECT DISTINCTROW qry_MillPricing.Facility, qry_MillPricing.Group,
qry_MillPricing.number, qry_MillPricing.productcode, qry_MillPricing.CustNum,
qry_MillPricing.Description, qry_MillPricing.species,
qry_MillPricing.subspecies, qry_MillPricing.texture, qry_MillPricing.Mill,
qry_MillPricing.[10KGBagPrice], qry_MillPricing.SellingUofM_XX,
qry_MillPricing.IUMRC_XX, qry_MillPricing.BCHLD_XX
FROM qry_MillPricing
UNION SELECT DISTINCTROW qry_MillPricing.Facility, qry_MillPricing.Group,
qry_MillPricing.number, qry_MillPricing.productcode, qry_MillPricing.CustNum,
qry_MillPricing.Description, qry_MillPricing.species,
qry_MillPricing.subspecies, qry_MillPricing.texture, qry_MillPricing.Mill,
qry_MillPricing.[20KGBagPrice], qry_MillPricing.SellingUofM_XX,
qry_MillPricing.IUMRC_XX, qry_MillPricing.BCHLD_XX
FROM qry_MillPricing
UNION SELECT DISTINCTROW qry_MillPricing.Facility, qry_MillPricing.Group,
qry_MillPricing.number, qry_MillPricing.productcode, qry_MillPricing.CustNum,
qry_MillPricing.Description, qry_MillPricing.species,
qry_MillPricing.subspecies, qry_MillPricing.texture, qry_MillPricing.Mill,
qry_MillPricing.[30KGBagPrice], qry_MillPricing.SellingUofM_XX,
qry_MillPricing.IUMRC_XX, qry_MillPricing.BCHLD_XX
FROM qry_MillPricing
UNION SELECT DISTINCTROW qry_MillPricing.Facility, qry_MillPricing.Group,
qry_MillPricing.number, qry_MillPricing.productcode, qry_MillPricing.CustNum,
qry_MillPricing.Description, qry_MillPricing.species,
qry_MillPricing.subspecies, qry_MillPricing.texture, qry_MillPricing.Mill,
qry_MillPricing.[227KGBagPrice], qry_MillPricing.SellingUofM_XX,
qry_MillPricing.IUMRC_XX, qry_MillPricing.BCHLD_XX
FROM qry_MillPricing
UNION SELECT DISTINCTROW qry_MillPricing.Facility, qry_MillPricing.Group,
qry_MillPricing.number, qry_MillPricing.productcode, qry_MillPricing.CustNum,
qry_MillPricing.Description, qry_MillPricing.species,
qry_MillPricing.subspecies, qry_MillPricing.texture, qry_MillPricing.Mill,
qry_MillPricing.PerKGPrice, qry_MillPricing.SellingUofM_XX,
qry_MillPricing.IUMRC_XX, qry_MillPricing.BCHLD_XX
FROM qry_MillPricing;