我正在做练习,而且我的输出有问题。 我的输出:
ABC 3 PQRS 4 //this Output is wrong
和我应该能够产生的输出:
ABC 3
PQRS 4 //this should be my Output
这是我的疑问:
select min(name) ,len(min(name)), max(name), len(max(name)) from customers
我怎么能两个回来? min(name)
len(min(name))
和max(name)
len(max(name))
两列中的package PongV2;
import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
public class Tennis extends Applet implements Runnable, KeyListener{
final int WIDTH = 700, HEIGHT = 500;
Thread thread;
HumanPaddle p1;
AIPaddle p2;
Ball b1;
boolean gameStarted;
Graphics gfx;
Image img;
public void init(){
this.resize(WIDTH, HEIGHT);
gameStarted = false;
this.addKeyListener(this);
p1 = new HumanPaddle(1);
b1 = new Ball();
p2 = new AIPaddle(2, b1);
img = createImage(WIDTH, HEIGHT);
gfx = img.getGraphics();
thread = new Thread(this);
thread.start();
}
public void paint(Graphics g){
gfx.setColor(Color.black);
gfx.fillRect(0, 0, WIDTH, HEIGHT);
if(b1.getX() < -10 || b1.getX() > 710){
gfx.setColor(Color.red);
gfx.drawString("Game Over", 350, 250);
}
else{
p1.draw(gfx);
b1.draw(gfx);
p2.draw(gfx);
}
if(!gameStarted) {
gfx.setColor(Color.white);
gfx.drawString("Pong", 343, 100);
gfx.drawString("Press Enter to Begin...", 295, 130);
}
g.drawImage(img, 0, 0, this);
}
public void update(Graphics g){
paint(g);
}
public void run() {
for(;;){
if(gameStarted) {
p1.move();
p2.move();
b1.move();
b1.checkPaddleCollision(p1, p2);
}
repaint();
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_UP) {
p1.setUpAccel(true);
} else if(e.getKeyCode() == KeyEvent.VK_DOWN){
p1.setDownAccel(true);
} else if(e.getKeyCode() == KeyEvent.VK_ENTER){
gameStarted = true;
}
}
public void keyReleased(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_UP) {
p1.setUpAccel(false);
} else if(e.getKeyCode() == KeyEvent.VK_DOWN){
p1.setDownAccel(false);
}
}
public void keyTyped(KeyEvent arg0) {
}
}
???
根据我的查询,我会返回结果,但显然只有四列,我需要将其返回到两列中,如上所示,在示例中...
答案 0 :(得分:4)
使用UNION
:
SELECT MIN(name) AS name, LEN(MIN(name)) AS length
FROM customers
UNION ALL
SELECT MAX(name) AS name, LEN(MAX(name)) AS length
FROM customers