線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1195
推到 Plurk!
推到 Facebook!

報表相關問題(再次發問)

答題得分者是:christie
g9614721
一般會員


發表:27
回覆:51
積分:15
註冊:2008-07-23

發送簡訊給我
#1 引用回覆 回覆 發表時間:2009-05-13 18:10:25 IP:140.125.xxx.xxx 訂閱
不好意思,之前發表的文章還是沒有解決問題,所以再次發問= ="

拜託幫我解答一下= ="弄了很久..

我用的是delphi7 和 內建的quick report


請問
(假設query1查詢後的資料有五筆)(四個欄位)
(假設query2查詢後的資料有兩筆)(三個欄位)
怎麼讓報表得到以下結果
使用地點最大領用量平均領用量使用人員
A10050
B10050
C10050
D10050
E10050
貯存地點最大庫存量平均庫存量
F10050
G10050


[code delphi]
date3:=DateTimePicker2.Date;
date4:=DateTimePicker3.Date;
with query5 do
begin
close;
sql.Clear;
SQL.Add('Select 使用地點、max(領用數量) as 最大領用量,avg(領用數量) as 平均領用量 、使用人員 from A_save2 ');
sql.Add('where 物品名稱="' dblookupcombobox1.text '" and (日期>=:date3)and (日期<=:date4) group by 使用地點,使用人員 ' );

end;
Query5.Params [0].DataType :=ftdate;
Query5.Params [0].Value :=date3;
Query5.Params [1].DataType :=ftdate;
Query5.Params [1].Value :=date4;
Query5.Active :=true;
date1:=DateTimePicker2.Date;
date2:=DateTimePicker3.Date;
with query6 do
begin
close;
sql.Clear;
SQL.Add('Select 貯存地點、max(庫存數量) as 最大庫存量,avg(庫存數量) as 平均庫存量 from A_save ');
sql.Add('where 物品名稱="' dblookupcombobox1.text '" and (日期>=:date1)and (日期<=:date2) group by 貯存地點 ' );

end;
Query6.Params [0].DataType :=ftdate;
Query6.Params [0].Value :=date1;
Query6.Params [1].DataType :=ftdate;
Query6.Params [1].Value :=date2;
Query6.Active :=true;

end;
[/code]



編輯記錄
g9614721 重新編輯於 2009-05-13 18:11:42, 註解 無‧
christie
資深會員


發表:30
回覆:299
積分:475
註冊:2005-03-25

發送簡訊給我
#2 引用回覆 回覆 發表時間:2009-05-14 11:07:47 IP:59.125.xxx.xxx 未訂閱

怎麼讓報表得到以下結果
使用地點最大領用量平均領用量使用人員
A10050
B10050
C10050
D10050
E10050
貯存地點最大庫存量平均庫存量
F10050
G10050
你可以將上面資料另寫到一個Table,再由QuickRep印出。
------
What do we live for if not to make life less difficult for each other?
g9614721
一般會員


發表:27
回覆:51
積分:15
註冊:2008-07-23

發送簡訊給我
#3 引用回覆 回覆 發表時間:2009-05-14 15:41:57 IP:140.125.xxx.xxx 訂閱
請問是這樣的做法嗎?
那請教一下,如何將query查詢出來的資料輸出= =?

[code delphi]
table1.append;
table1.fieldbyname('欄位1').asstring:='使用地點';
table1.fieldbyname('欄位2').asstring:='最大領用量';
table1.fieldbyname('欄位3').asstring:='平均領用量';
table1.fieldbyname('欄位4').asstring:='使用人員';
table1.post;

table1.append;
(這邊如何輸入query5的多筆資料)
table1.post

table1.append;
table1.fieldbyname('欄位1').asstring:='貯存地點;
table1.fieldbyname('欄位2').asstring:='最大貯存量';
table1.fieldbyname('欄位3').asstring:='平均貯存量';
table1.post;

table1.append;
(這邊如何輸入query6的多筆資料)
table1.post;

[/code]
;
;


===================引 用 christie 文 章===================

怎麼讓報表得到以下結果
使用地點最大領用量平均領用量使用人員
A10050
B10050
C10050
D10050
E10050
貯存地點最大庫存量平均庫存量
F10050
G10050
你可以將上面資料另寫到一個Table,再由QuickRep印出。
christie
資深會員


發表:30
回覆:299
積分:475
註冊:2005-03-25

發送簡訊給我
#4 引用回覆 回覆 發表時間:2009-05-14 16:55:20 IP:59.125.xxx.xxx 未訂閱
Query5.Active :=true; // 或 Query5.Open

while not Query5.Eof do
begin
Table1.Append;
Table1.fieldbyname('欄位1').asstring:=Query5.Fields[0].AsString;
Table1.fieldbyname('欄位2').asstring:=Query5.Fields[1].AsString;
Table1.fieldbyname('欄位3').asstring:=Query5.Fields[2].AsString;
Table1.fieldbyname('欄位4').asstring:=Query5.Fields[3].AsString;
Table1.Post;

Query5.Next
end;
------
What do we live for if not to make life less difficult for each other?
g9614721
一般會員


發表:27
回覆:51
積分:15
註冊:2008-07-23

發送簡訊給我
#5 引用回覆 回覆 發表時間:2009-05-14 23:42:16 IP:140.125.xxx.xxx 訂閱
請教一下 query5.next 的用意是?
另外,這樣不就每次都要把table1給清乾淨,
請問怎麼一次把table1的資料都清空?@@
===================引 用 christie 文 章===================
Query5.Active :=true; // 或 Query5.Open

while not Query5.Eof do
begin
Table1.Append;
Table1.fieldbyname('欄位1').asstring:=Query5.Fields[0].AsString;
Table1.fieldbyname('欄位2').asstring:=Query5.Fields[1].AsString;
Table1.fieldbyname('欄位3').asstring:=Query5.Fields[2].AsString;
Table1.fieldbyname('欄位4').asstring:=Query5.Fields[3].AsString;
Table1.Post;

Query5.Next
end;
christie
資深會員


發表:30
回覆:299
積分:475
註冊:2005-03-25

發送簡訊給我
#6 引用回覆 回覆 發表時間:2009-05-15 08:33:40 IP:59.125.xxx.xxx 未訂閱
問一?
A:
****************
TDataSet.Next
****************

Moves to the next record in the dataset.
procedure Next;
Description
Call Next to move to the next record in the dataset, making it the active record. Next posts any changes to the active record and
Sets the Bof and Eof properties to False.
Fetches the next record and makes it the active record.
If the dataset is not unidirectional, fetches any additional records required for display, such as those needed to fill out a grid control.
Sets the Eof property to True if the last record in the dataset was already active.
Broadcasts the record change so that data controls and linked detail sets can update.
Note: TDataSet uses internal, protected methods to move the active record and to fetch additional records required for display. In TDataSet, these internal methods are empty stubs. Descendant classes implement these methods to enable the Next method to work.
===================引 用 g9614721 文 章===================
請教一下 query5.next 的用意是?
另外,這樣不就每次都要把table1給清乾淨,
請問怎麼一次把table1的資料都清空?@@
===================引 用 christie 文 章===================
Query5.Active :=true
; // 或 Query5.Open

while not Query5.Eof do
begin
Table1.Append;
Table1.fieldbyname('欄位1').asstring:=Query5.Fields[0].AsString;
Table1.fieldbyname('欄位2').asstring:=Query5.Fields[1].AsString;
Table1.fieldbyname('欄位3').asstring:=Query5.Fields[2].AsString;
Table1.fieldbyname('欄位4').asstring:=Query5.Fields[3].AsString;
Table1.Post;

Query5.Next
end;


------
What do we live for if not to make life less difficult for each other?
christie
資深會員


發表:30
回覆:299
積分:475
註冊:2005-03-25

發送簡訊給我
#7 引用回覆 回覆 發表時間:2009-05-15 08:35:52 IP:59.125.xxx.xxx 未訂閱
問二
請問怎麼一次把table1的資料都清空?
A:
Delete from Table1;
------
What do we live for if not to make life less difficult for each other?
g9614721
一般會員


發表:27
回覆:51
積分:15
註冊:2008-07-23

發送簡訊給我
#8 引用回覆 回覆 發表時間:2009-05-15 12:36:12 IP:140.125.xxx.xxx 訂閱
thanks
===================引 用 christie 文 章===================
問二
請問怎麼一次把table1的資料都清空?
A:
Delete from Table1;
系統時間:2024-05-17 5:27:15
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!