sql查询疑问
表中按datadate,tradeid为主键,也就是说tradeid会重复出现在不同天中,同一天的tradeid是不同的。现在我希望取一段时间范围内不重复的tradeid,且只要每个tradeid的最后一次出现的那条。sql语句该怎么写
:
select 最大的(datadate),tradeid,其他字段..... from 表 where datadate>='20090801' and datadate <='20090831' group by tradeid
能否做成视图? 查询视图日起范围动态的变化,
[Quote=引用 2 楼 oceanmeng 的回复:]
能否做成视图? 查询视图日起范围动态的变化,
[/Quote]
視圖不支持參照,可用存儲過程
樓主的意思是日期做成變量 傳參?
那做成存儲過程吧
OK,xiexie
相关问答:
with adod_dict do
begin
close;
commandtext:='select bgqxcode,count(*) wjsl from wscl_wsda_file where wjnd=:tnd group by bgqxcode'; ......
前几天公司面试,见到一题,请高手帮我解答,谢谢!
内容table:
id name parentid
1 aaa null
14 bbb 1
......
我EXCEL中一个单元格的数据如 "2009-01","8949-232"
将这个数据粘贴到PL/SQL中的一个表中后,数据确是成为了 2009-01,8949-232 ,把所有的""都没了,
如何弄呢?请大家试 ......
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 ......
SELECT Count(*) from In_fo WHERE Reader_Time between #" + time1 + "# AND #" + time2 + "# and id=" + userid + ";
上面是我写的sql语句 Reader_Time是时间类型 id为数字 ......