Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
OBINNA_EKE
Posting Yak Master
234 Posts |
Posted - 2006-09-21 : 06:25:32
|
I am displaying record sets like thisWhile (NOT rsEquipments.EOF) SQL = SQL & "<tr bgcolor=''> " SQL = SQL & "<td class='ColTitles'>"&k&" </td>" SQL = SQL & "<td class='ColTitles'>"&rsEquipments.Fields.Item("RMANo").value&" </td>" SQL = SQL & "<td class='ColTitles'>"&UCase(rsEquipments.Fields.Item("SerialNo").Value)&" </td>" SQL = SQL & "<td class='ColTitles'>"&rsEquipments.Fields.Item("QTy").value&" </td>" SQL = SQL & "<td class='ColTitles'>"&rsEquipments.Fields.Item("Model").value&" </td>" SQL = SQL & "<td class='ColTitles'>"&ChangeTypeText(rsEquipments.Fields.Item("Type").value)&" </td>" SQL = SQL & "</tr>" k = k + 1 SaveLog rsEquipments.Fields.Item("RMANo").value , rsEquipments.Fields.Item("SubCustomerContactID").value Repeat1__index=Repeat1__index+1 Repeat1__numRows=Repeat1__numRows-1 'Response.Write("<br>RMA is "&rsEquipments.Fields.Item("RMANo").value) rsEquipments.MoveNext() WendThis is the output# RMA No: Serial No: Qty Model Type1 13751 2PNC00534E9S9VC 1 TS Clear SRM2000 Batch2 8725 2PNC00534E9S9XP 1 TS Clear SRM2000 BatchThe Output I want now is # QTY Serial No: Model 1 2 (13751-2PNC00534E9S9VC)(8725-2PNC00534E9S9XP)Model As you can see that the two equipment has got the same model there it should be on the same row and qty calculated as wellThanksIf it is that easy, everybody will be doing it |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-09-21 : 06:53:42
|
I think we you have teached you before how to concat rows.Feel free to search this site for row concatening functions.Peter LarssonHelsingborg, Sweden |
 |
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-09-21 : 16:37:46
|
Something like this should workDim LastModel, SerialNumber, QtyLastModel = -1While (NOT rsEquipments.EOF)If LastModel = rsEquipments.Fields.Item("Model").value Then SerialNumber = SerialNumber & "(" & UCase(rsEquipments.Fields.Item("SerialNo").Value) & ")" Qty = Qty + rsEquipments.Fields.Item("Qty").valueElse If LastModel <> -1 Then SQL = SQL & "<tr bgcolor=''> " SQL = SQL & "<td class='ColTitles'>"&k&" </td>" SQL = SQL & "<td class='ColTitles'>"&Qty&" </td>" SQL = SQL & "<td class='ColTitles'>"&SerialNumber&" </td>" SQL = SQL & "<td class='ColTitles'>"&LastModel&" </td>" SQL = SQL & "</tr>" End If SerialNumber = "(" & UCase(rsEquipments.Fields.Item("SerialNo").Value) & ")" Qty = rsEquipments.Fields.Item("Qty").value LastModel = rsEquipments.Fields.Item("Model").value k = k + 1 End IfSaveLog rsEquipments.Fields.Item("RMANo").value , rsEquipments.Fields.Item("SubCustomerContactID").valueRepeat1__index=Repeat1__index+1Repeat1__numRows=Repeat1__numRows-1'Response.Write("<br>RMA is "&rsEquipments.Fields.Item("RMANo").value)rsEquipments.MoveNext()Wend |
 |
|
|
|
|