I am trying to create a CSV file that lists each state only once as well as each zip code for the state only once. Instead I am getting the states listed over and over and the zip code listed over and over. Could someone please teach me how to do this properly. Below is a sample of the data being created and below that is my sql query.CA 92345 7.75 0CA 92345 7.75 2.32CA 92345 7.75 2.55CA 92345 7.75 2.79CA 92345 7.75 3.1CA 92346 7.75 1.39CA 92363 7.75 2.79CA 92371 7.75 3.1CA 92372 7.75 0.46CA 92374 7.75 0.23CA 92376 7.75 0CA 92392 7.75 0CA 92392 7.75 0.92CA 92392 7.75 2.32CA 92392 7.75 2.79CA 92392 7.75 11.61CA 92392 7.75 15.5CA 92394 7.75 0.46CA 92395 7.75 0CA 92395 7.75 0.15CA 92395 7.75 1.86CA 92395 7.75 2.32CA 92397 7.75 0CA 92399 7.75 2.32CA 92399 7.75 15.5CA 92404 7.75 0CA 92404 7.75 2.32CA 92405 8 0CA 92405 8 1.76CA 92407 7.75 0CA 92407 7.75 0.79
Here is my query:SELECT DISTINCT o.ShipState AS 'U.S. State', t.TaxPostalCode AS 'Zip Code', t.Tax1_Percent AS 'Tax Rate', SUM( o.SalesTax1 ) AS 'Total Sales Tax'FROM Orders AS oINNER JOIN Tax AS t ON o.ShipPostalCode = t.TaxPostalCodeGROUP BY o.ShipState, t.TaxPostalCode, t.Tax1_Percent, o.SalesTax1ORDER BY o.ShipState, t.TaxPostalCode, t.Tax1_Percent