帮忙写这个SQL查询语句
有这么一个表:
id | name | age | item
1 | tom | 12 | 1
2 | cat | 23 | 2
3 | ... | 36 | 3
4 | ... | 15 | 4
5 | ... | 26 | 2
6 | ... | 16 | 1
.......
找出 item=3的age 且 其他age小于item=3的age
找出 item=3的age 且 其他age小于item=3的age
很好,很强大的要求,一个字都没看懂!
看完我就迷糊了,哈哈哈,果子,看完你回的,我实在忍不住,这要求笑死我了~~
咬文嚼字半天~~,楼主是不是要把item <=3的age查出来呀??
select * from 表名 where item=3 and age <ALL(select age from 表名 where item=3);
...楼主意思是不是 找出item=3的 age最小的那条数据?
先取出item=3 再按年龄升序 取第一条
比较难懂
select age from 这个表名 where item <=3;
你的表达能力实在不是一般..不过我非常人...
4楼说的是不是这样可以实现
select top 1 * from 表名 where item=3 group by
相关问答:
sql2005
select *from v_ddxx where d_sfsc='0' and (g_ssbm='1001' or g_ssbm='1002') and (xxf>0 and xxfwzf <>0 ),执行速度慢的要死,但是如果把(xxf>0 and ......
我的语句为str1.Format("UPDATE wz set title='%s',class='%s',nr='%s',[date]='%s' WHERE num='%d'",
m_bt, strTemp, fromClipboard, time5,m_num);
......
表A 内 有id 和 name
希望根据A表的name进行查询,但是name可能会重复,所以需要判断.
有一个sql函数 f ,它的参数是A表的id字段,返回一个值.
我希望最后得到一个表,包含id name 和[最后函数f返回 ......
SQL code:
1. 说明:复制表(只复制结构,源表名:a,新表名:b)
SQL: select * into b from a where 1<>1;
2. 说明:拷贝表(拷贝数据,源表名:a,目标表名:b)
SQL: insert into b(a ......