How to get Multiple Row Values

2019-02-21 03:22发布

问题:

It is the question in continuation to my old post. If you want to see the codes of the below image then follow the below link, and solve my problem please.

How to Multiply two Column values and display its Result at the end of each Row?

stackoverflow.com/questions/11202617/how-to-multiply-two-column-values-and-display-its-result-at-the-end-of-each-row/11203135

Image

http://www.koolfree.com/ImageUpload/uploads/1341093148.jpg

Question

I have attached a link of Screenshot. Kindly see the Screenshot and tell me how can I add multiple jobs per user ID?

For Example, Screenshot have User ID 216020 and the user has Two Job Locations rows i.e. Civil and Office Work, it has Two Salary rows i.e. 150 and 200, it has Two Allowance rows i.e. 0 and 0, it has Two Days rows i.e. 17 and 13, finally it has Two Total rows i.e. 1950 and 2600 (Total is generated through the Multiplication of Salary and Days) and there is a Total of Total at the end of the Table. I am not able to get multiple row values per user ID. Kindly tell me how can I get those row values per User ID?

回答1:

Given MyTable of ID,A1,A2,B1,B2,C1,C2

then it's just something like

Select ID,A1 AS Value1 ,B1 as Value2 ,C1 AS Value3
From MyTable
Union All
Select ID,A2,B2,C2
From MyTable

Surely???



标签: rows