编写一个查询以从sql表中获取所需的内容 [英] write a query to get desired out from sql tables

查看:45
本文介绍了编写一个查询以从sql表中获取所需的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://stackoverflow.com/questions/25033601 / write-a-query-to-get-desired-sql-table-output [ ^ ]点击链接获取表格和所需的输出。这个问题是由一家公司在技术考试中提出的。我无法回答。请告诉我如何获得解决方案。

http://stackoverflow.com/questions/25033601/write-a-query-to-get-desired-sql-table-output[^] click on the link to get the tables and desired output. This question is asked by a company at technical exam. I could not given answer. Please tell me how can i get the solution.

推荐答案

SELECT
M.EMPID
,CASE WHEN M.ID = 1 THEN TA.NAME
      WHEN M.ID = 2 THEN TB.NAME
      WHEN M.ID = 3 THEN TC.NAME
      WHEN M.ID = 4 THEN TD.NAME
FROM
MASTER M
LEFT JOIN TABLEA  TA ON TA.EMPID = M.EMPID
LEFT JOIN TABLEB  TA ON TB.EMPID = M.EMPID
LEFT JOIN TABLEB  TC ON TC.EMPID = M.EMPID
LEFT JOIN TABLEB  TD ON TD.EMPID = M.EMPID


我们不是来做你的功课 - 如果你甚至不愿意在这里发布实际的问题对我们来说,为什么我们要打扰你呢?



如果你不能回答,那么这会告诉公司很多关于你的事情。如果我们回答,这会告诉公司很多关于我们的事情:但是你找到了工作,而不是我们,而且我们可以完成工作,而不是你。



自己动手:它并不复杂!
We are not here to "do your homework" - and if you can't even be bothered to post the actual question here for us, why should we be bothered to help you either?

If you can't answer, then that tells the company a lot about you. If we answer, that tells the company a lot about us: but it's you that gets the job, not us, and it's us that can do the work, not you.

Try it yourself: it's not exactly complicated!


这篇关于编写一个查询以从sql表中获取所需的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆