有人可以请帮助我。我正在尝试做一些看起来非常简单和容易的事情。但我似乎无法弄清楚。
我试图将我的数据显示为数据透视表而不是“正常呈现”这就是现在的样子。
Store, Product, amount
store1, potatoes, 10
store2, strawberry, 20
但我想要的是:
Product Store1 Store2 Total
potatoes 10 10
strawberry 20 20
这是我使用的代码:
Dim rsMenu1
Set rsMenu1 = Server.CreateObject("ADODB.Recordset")
rsMenu1.ActiveConnection = ConnectString
dim sql
sql = "SELECT store.storeOms, datepart(wk,voorraad.datum) as week, products.prodOms, SUM (voorraad.besteld) AS besteld FROM products"
sql = sql & " INNER JOIN voorraad ON products.prodId = voorraad.prodId INNER JOIN store "
sql = sql & " ON voorraad.storeId = store.storeId "
sql = sql & " WHERE datepart(wk,datum) =" & request.querystring("q")
sql = sql & " AND voorraad.besteld > 0"
sql = sql & " GROUP BY store.storeOms, voorraad.datum, products.prodOms"
response.Write(sql)
rsMenu1.Source = sql
rsMenu1.Open()
%>
<table width="200" border="0" class="table table-hover">
<tr>
<th>Winkel</th>
<th>Product</th>
<th>Aantal besteld</th>
</tr>
<%do until rsMenu1.EOF%>
<tr>
<td><%=rsMenu1.Fields.Item("storeOms").Value%></td>
<td><%=rsMenu1.Fields.Item("prodOms").Value%></td>
<td><%=rsMenu1.Fields.Item("besteld").Value%></td>
</tr>
<%rsMenu1.Movenext
Loop%>