我有3张桌子
GstElement *pipeline_2= gst_parse_launch("udpsrc port=20000 ! application/x-rtp,encoding-name=JPEG,payload=26 ! rtpjpegdepay ! jpegparse ! jpegdec ! videoconvert ! videoscale ! ximagesink name=mySink", NULL);
GstElement *sink = gst_bin_get_by_name((GstBin*)pipeline_2,"mySink");
QWidget *window = new QWidget();
window->setWindowTitle("udpsrc video stream");
window->resize(700, 700);
WId xwinid = window->winId();
gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (sink), (guintptr)xwinid);
window->show();
GstStateChangeReturn sret = gst_element_set_state (pipeline_2, GST_STATE_PLAYING);
现在我需要使用适当的数据来获得最高薪水行。
像Emp id 1一样,最高工资= 30,0000,因此从a / c表中获取整行id = 2 Emp id 2最高工资= 20,000,因此从空调表中获取整行id = 3
我尝试
Employee
---------------
ID Name
1 John
2 Kelly
3 Leo
Dept
-------
ID Name
1 Finance
2 A/c
3 Marketing
Accout
--------------------
Id EmpId Dept Sal
1 1 1 25,000
2 1 2 30,000
3 2 2 20,000
4 2 1 15,000
5 3 3 20,000
所以我得到的结果是
SELECT E.id,E.name AS emp_name,D.name AS dept_name,
A.Dept as dept_id,max(A.sal) AS max_sal
FROM Accout A
JOIN Employee E ON A.EmpId = E.ID
JOIN Dept D ON A.Dept = D.Id
Group by EmpId
但是我需要这样的结果
Id emp_name dept_name dept_id max_sal
1 John Finance 1 30,000
2 Kelly A/c 2 20,000
3 Leo Marketing 3 20,000
请让我知道怎么可能,这样我才能获得正确的输出。
谢谢。
答案 0 :(得分:0)
我使用GROUP BY
而不是使用ORDER BY
,因为您说过您只想从最高到最低薪水,另外我还删除了max()
:
SELECT E.id
E.name AS emp_name,
D.name AS dept_name,
A.DeptId as dept_id,
A.sal AS max_sal
FROM Account A
JOIN Employee E ON A.EmpId = E.ID
JOIN Dept D ON A.DeptId = D.Id
ORDER BY max_sal DESC
LIMIT 3
如果要限制返回的行,可以使用LIMIT
答案 1 :(得分:0)
您需要先找到最高薪水行,然后再与其他表连接。 该查询将为您工作。
SELECT
E.id, E.name AS emp_name, D.name AS dept_name, A.Dept AS dept_id, max_sal
FROM
Accout A
JOIN
(SELECT
EmpId, MAX(sal) AS max_sal FROM
Accout GROUP BY EmpId
) B ON A.EmpId = B.EmpId AND A.sal = B.max_sal
JOIN Employee E ON A.EmpId = E.ID
JOIN Dept D ON A.Dept = D.Id;