 |
|
VB.Net สินค้าที่ขายดีที่สุด 5 อันดับ มันไม่ยอม Sum อะคะ มันเลือกที่ยอดจำนวนสูงสุด ขอบคุณคะ |
|
 |
|
|
 |
 |
|
โค้ดตามนี้เลยคะ โค้ดมันจะเลือกที่ขายสูงสุด 5 อันดับ แต่ไม่เลือก ที่ รวมแล้วขายดี 5 อันดับอะคะ
ภาษา vb ขอบคุณคะ
Code (VB.NET)
SQLConnection.Close()
SQLConnection.Open()
Dim where As String = ""
where = "and b.status like '%" + TextBox1.Text + "%' group BY amount DESC LIMIT 0,5 "
Dim cryrpt As New cry_producttop
SQLStatement = "select a.bill_id,a.ps_date,a.sum_price,a.emp_id,a.cus_id,a.status,b.pro_id,b.pro_name,b.amount,SUM(b.amount),b.pro_price,b.tax_sell,b.status from product_sell a left join product_sell_detail b on a.bill_id = b.bill_id where a.ps_date between '" + Convert.ToDateTime(DateTimePicker1.Text).ToString("yyyy-MM-dd", New System.Globalization.CultureInfo("en-US")) + "' and '" + Convert.ToDateTime(DateTimePicker2.Text).ToString("yyyy-MM-dd", New System.Globalization.CultureInfo("en-US")) + "' " + where
cmd = New MySqlCommand(SQLStatement, SQLConnection)
Dim a As MySqlDataReader = cmd.ExecuteReader
If a.HasRows Then
dt = New DataTable
dt.Load(a)
cryrpt.SetDataSource(dt)
CrystalReportViewer1.ReportSource = cryrpt
cryrpt.SetParameterValue("date_from", DateTimePicker1.Text)
cryrpt.SetParameterValue("date_to", DateTimePicker2.Text)
Label3.Text = ""
Else
CrystalReportViewer1.ReportSource = Nothing
MessageBox.Show("ไม่พบข้อมูล")
End If
CrystalReportViewer1.Refresh()
SQLConnection.Close()
End Sub
Tag : .NET, MySQL, VB.NET, VS 2010 (.NET 4.x)
|
|
 |
 |
 |
 |
Date :
2013-05-12 13:26:41 |
By :
meawja |
View :
1235 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Capture ตัว Table ที่เป็น Order Detail มาให้ดูหน่อยครับ
|
 |
 |
 |
 |
Date :
2013-05-13 06:35:35 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แบบของผมนี้ก็ น่าจะใช้ได้นะครับ
Code (VB.NET)
sb.Append("SELECT TOP 5 ProductName,SUM(Amount) FROM CashSaleDetails")
sb.Append(" GROUP BY ProductName")
sb.Append(" ORDER BY SUM(Amount) DESC")
|
 |
 |
 |
 |
Date :
2013-05-13 15:13:08 |
By :
Gumbee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|