แสดงกระทู้

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Nantnapus

หน้า: [1]
1
ห้อง MS Access / : Running Number ใน Query Group By Type
« เมื่อ: 28 เม.ย. 62 , 17:18:02 »
RunningNo.    Price      Type
1                   100        A
2                   120        A
3                   130        A
1                   80          B
2                   90          B
1                   78          C
2                   80          C
3                   90          C
4                  100         C

ไม่ทราบว่า ใน Query แบบนี้ ต้องทำเช่นไรครับผม  :question:

ตามนี้เลยคับ
ผมสมมุติตารางที่ทำชื่อ Table1 นะครับ มีฟิล์ Type กับ Price ตามตัวอย่าง

SELECT T.*, (select count(*) from Table1 where T.Price>=Price and  T.Type=Type) AS RunningNo
FROM Table1 AS T
ORDER BY T.Type, T.Price;
โพสต์นี้ได้รับคำขอบคุณจาก: Nantnapus

หน้า: [1]