How to make this query?

  • Thread starter Thread starter Su
  • Start date Start date
S

Su

Hello,

Got a question for the expert!

I got a table which like

BH Date Benzene Ethylene Xylene
BH1 ?? 1 2 3


How can I convert it to sth like this

BH Date Contaminant Result
BH1 ?? Benzene 1
BH1 ?? Ethylene 2
BH1 ?? Xylene 3

Many thanks!

Su
 
Your table is un-normalized which generally requires a Union query to
normalize:
SELECT BH, [Date] as ReadingDate, "Benzene" as Contaminant, [Benzene] as
Result
FROM tblA
UNION ALL
SELECT BH, [Date] , "Ethylene", [Ethylene]
FROM tblA
UNION ALL
SELECT BH, [Date] , "Xylene", [Xylene]
FROM tblA;
 
Back
Top