fname lname id
a null 101
null p 101
b null 102
null q 102
c null 103
null r 103
我想要这样的输出:`
fname lname id
a p 101
b q 102
c r 103
答案 0 :(得分:2)
这些真的是你想要的结果吗?他们没有制作,因为你现在已经重复了两次id和你的agregation应该101和101组合,然后102和103和102与103 ????如果你搞砸了你的结果,只需要收集总量。
SELECT
MIN(id) AS id
,MAX(fname) as fname
,MAX(lname) as lname
,empid
FROM
TableName
GROUP BY
empid
答案 1 :(得分:1)
只需将表连接到自身 - 一个用于fname,一个用于lname
<link rel='import' href='../polymer/polymer.html'>
<link rel='import' href='../app-localize-behavior/app-localize-behavior.html'>
<link rel='import' href='../paper-button/paper-button.html'>
<dom-module id='client'>
<template>
<div class='buttonContainer'>
<paper-button raised id='closeChat' class="green">{{localize('agent.closeChat')}}</paper-button>
</div>
</template>
<script>
Client = Polymer({
is: "client-interface",
behaviors: [
Polymer.AppLocalizeBehavior
],
// works as expected
attached: function() {
this.loadResources(this.resolveUrl('./locales.json'))
},
</script>
</dom-module>