I have a query that selects companyName
and department
from the database. When I display on my website, it will be order by companyName
.
When I add select productSold
from the department, my department got separated into 2 records if there are 2 productSold
. Is there anyway I can display 1 department with 2 records in the table.
Thanks.
My query is as follows:
SELECT dbo.CompanyAdd.companyName,
dbo.OrderDetails.department,
dbo.OrderDetails.productSold
FROM dbo.CompanyAdd
INNER JOIN
dbo.OrderDetails
GROUP BY dbo.CompanyAdd.companyName,
dbo.OrderDetails.department,
dbo.OrderDetails.productSold
HAVING (dbo.User2Company.UsrID = 10)
ORDER BY
dbo.OrderDetails.department;
This is my code to check if previous record is same as current.
<% dim productSold
Do While Not registerRS.EOF
Response.write"<table>"
Response.write "<tr>" %>
<td height="265.6" width="264.56">
<%=rS.Fields("companyName")%> <br />
<%=rS.Fields("department") %><br />
<%=rS.Fields("productSold") %><br />
</td>
<%
Response.write "</tr>"
If r = 4 then r = 1
'Next
if rS.Fields("productSold") <> productSold then
Response.write("productSold:" & productSold)
end if
rS.movenext
loop
Response.write "</table> "
rS.close
set rS=nothing
%>