select n.cpzh,n.czxm,n.wzsj,a.haoma from newjtcx n ,anewjt a 
where n.cpzh=a.haopai and n.hpzl=a.haopaizl如上的语句 两个表 我想找max(n.wzsj) 应该怎么写语句啊? 谢谢了

解决方案 »

  1.   

     n.cpzh,n.czxm,n.wzsj,a.haoma  这些字段还要查出来的 只不过wzsj这个字段要变成max(wzsj)
      

  2.   

    没有 只要n.cpzh=a.haopai and n.hpzl=a.haopaizl  俩表中这两个字段对上就可以
      

  3.   

    select n.cpzh,n.czxm,MAX(n.wzsj),a.haoma from newjtcx n ,anewjt a  
    where n.cpzh=a.haopai and n.hpzl=a.haopaizl
    GROUP BY n.cpzh,n.czxm,a.haoma 
      

  4.   

    4楼得正解   现在问题是anewjt中有的数据在newjtcx表中可能没有  如果没有的话能不能也查出来 n.cpzh,n.czxm,MAX(n.wzsj),这三位补个一样的值 语句能实现吗? 外连接可以吧?
      

  5.   

    可以 看一下 left join 、 right join 、 decode的使用
      

  6.   

    select n.cpzh,n.czxm,max(n.wzsj),a.haoma from newjtcx n ,anewjt a  
    where n.cpzh=a.haopai and n.hpzl=a.haopaizl
    group by n.cpzh, n.czxm, a.haoma