$id = $_REQUEST['txtid'];
$startdatebill = $_GET['txtstart'];
$enddatebill = $_GET['txtend'];
$strSQL = "SELECT SUM(b.iMoney) AS IMONEY,
SUM(b.iQuantity) AS IQTY,
CONVERT(nvarchar, a.dDate,1)AS Imonths
FROM SaleBillVouch AS a RIGHT OUTER JOIN
SaleBillVouchs AS b ON a.SBVID = b.SBVID
WHERE (a.dDate BETWEEN '$startdatebill' AND '$enddatebill')
AND b.cInvCode = '$id'
GROUP BY CONVERT(nvarchar, a.dDate,1)
ORDER BY CONVERT(nvarchar, a.dDate,1)";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
$id = $_REQUEST['txtid'];
$startdatebill = $_GET['txtstart'];
$enddatebill = $_GET['txtend'];
$strSQL = "SELECT SUM(b.iMoney) AS IMONEY,
SUM(b.iQuantity) AS IQTY,
CONVERT(nvarchar, a.dDate,1)AS Imonths
FROM SaleBillVouch AS a RIGHT OUTER JOIN
SaleBillVouchs AS b ON a.SBVID = b.SBVID
WHERE (a.dDate BETWEEN '$startdatebill' AND '$enddatebill')
AND b.cInvCode = '$id'
GROUP BY CONVERT(nvarchar, a.dDate,1)
ORDER BY CONVERT(nvarchar, a.dDate,1)";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
Warning: mssql_query() [function.mssql-query]: message: Column 'SaleBillVouch.dDate' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
คำเตือน: mssql_query () [function.mssql-query]: ข้อความ: คอลัมน์ 'SaleBillVouch.dDate' ไม่ถูกต้องในรายการเลือกเพราะไม่ได้มีอยู่ในทั้งฟังก์ชันการรวมหรือคำสั่ง GROUP BY
"SELECT
MONTH(a.dDate) AS IMON,
YEAR(a.dDate) AS IYEAR,
SUM(b.iMoney) AS IMONEY,
SUM(b.iQuantity) AS IQTY
FROM SaleBillVouch AS a RIGHT OUTER JOIN
SaleBillVouchs AS b ON a.SBVID = b.SBVID
WHERE (a.dDate BETWEEN '$startdatebill' AND '$enddatebill')
AND b.cInvCode = '$id'
GROUP BY MONTH (a.dDate), YEAR (a.dDate)
";