![]() The field names in the second SELECT statement can be different, but must have the same data type. The second Union Select, the field names will be ignored. In the resulting query, the field names will be those contained in the first SELECT statement. WHERE = is like setting the criteria in a query. These need to be used and are separated by a comma.įROM = the table where the fields are located. SELECT = the fields you wish to select for the query. I will give you a few definitions before I give you the SQL, which will solve the above two problems. On the Ribbon > Create > Design View > Close Then, on the toolbar, > Query > SQL specific > UnionĪ window will open for you to write a SQL query. To do achieve the above will take a few steps:įirst of all you will need to create a union query to put all the colors into one field and the associated cost into another field, instead of the two fields you have for each currently. ![]() Month Code of colour Description Sum of cost caused by this colour January 112 white $115.00 125 yellow $12.00 900 brown $54.00 total cost $181.00 February 488 green $47.00 total cost $47.00 Id Month Code of color1 Code of color2 Cost of color1 Cost of color2 1 January 112 112 100 15 2 January 125 900 12 54 3 February 488 47 5 March 1000 15 6 March 800 26 7 April 800 10Ĭurrently I want to do a report to do a balance of the cost for each month, in addition to this I would like the description of colour to appear. Id colour 100 Blue 112 White 125 Yellow 488 Green 489 Red 500 Pale Blue 800 Grey 900 Brown 1000 Dark GrĪnd I also have another table where the information is introduced via a form: This tip Union Query Example Two Summing the Total of Two Fields in the Same Table uses a question as its basis, but explains how to sum the total of two fields that are in the same table, by the use of a Union Query. ![]() Summing the Total of Two Fields in the Same Table
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |