 |
ใช้คำสั่งsum like อยากให้ช่วยadd code ให้หน่อยครับคือ ต้องการดึง filed valuetime จากtable oee มา sum เฉพาะ "tr" |
|
 |
|
|
 |
 |
|
Select Sum(ValueItem) as ValueItem
From oee
Where item like 'tr%'
|
 |
 |
 |
 |
Date :
2009-06-24 14:09:25 |
By :
kittipongs |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
error แบบนี้ครับ
Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Circular reference caused by alias 'ValueItem' in query definition's SELECT list., SQL state S1000 in SQLExecDirect in C:\AppServ\www\phpweb\oee2.php on line 22
Error Execute [Select Sum(ValueItem) as ValueItem From oee Where item like 'tr%']
|
 |
 |
 |
 |
Date :
2009-06-24 16:12:52 |
By :
pongsatorn06 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
error ช่วยด้วย
$objConnect = odbc_connect("oee","","") or die("Error Connect to Database");
$sumtr="Select Sum(ValueItem) as ValueItem From oee Where item like 'tr%'";
$objExec = odbc_exec($objConnect, $sumtr) or die ("Error Execute [".$sumtr."]");
$Num_Rows = 0;
while(odbc_fetch_row($objExec))$Num_Rows++; // Count Record
|
 |
 |
 |
 |
Date :
2009-06-24 17:53:10 |
By :
pongsatorn06 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วครับแต่ sumออกมาแล้ว เป็นแบบนี้
แก้ยังไง อะครับ
item
0.58619212962963
<?
$objConnect = odbc_connect("oee","","") or die("Error Connect to Database");//SELECT SUM(Column/Field) AS [New-Field] FROM [Table-Name]
$sumtr ="Select Sum(Valuetime) as ValueItem From oee Where item like 'tr%' ";
$objExec = odbc_exec($objConnect, $sumtr) or die ("Error Execute [".$sumtr."]");
$Num_Rows = 0;
while(odbc_fetch_row($objExec))$Num_Rows++; // Count Record "SELECT SUM(valuetime) AS [sumvalue] FROM [oee] "
?>
|
 |
 |
 |
 |
Date :
2009-06-25 14:18:34 |
By :
pongsatorn06 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|