 |
คิวรี่ข้อมูลใน ms sql server แล้วเรียงลำดับตาม มูลค่าอย่างไรครับ |
|
 |
|
|
 |
 |
|
ขอดู code
|
 |
 |
 |
 |
Date :
2016-06-24 11:30:00 |
By :
dudesaranyu |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (SQL)
select ROW_NUMBER() OVER(ORDER BY price ) AS Row,Code,price from
(
select Code,price,count(*) as c_num
from tb_xxxx
group by Code
)a where c_num > 1 order by price
ผิดตรงไหนไปแก้เองนะครับ
|
 |
 |
 |
 |
Date :
2016-06-24 11:44:12 |
By :
gaowteen |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอบความคิดเห็นที่ : 1 เขียนโดย : dudesaranyu เมื่อวันที่ 2016-06-24 11:30:00
รายละเอียดของการตอบ ::
โค้ดครับ ผมทำได้แค่เรียง รวม ไม่สามารถแยก เรียงตาม โค้ดได้
ช่วยชี้แนะด้วยครับ
Code (PHP)
select row_number() OVER (order by hs_no asc,value_usd desc) AS 'NO',hs_no,month,country_code,value_usd from
/*2*/
(select
hs_no,month,country_code
,sum(value_usd) as value_usd
from
/*1*/
(SELECT substring(HS_NO,1,8) as hs_no
,[COUNTRY_CODE]
,substring(month,1,4) as month
,[QUANTITY]
,[VALUE_THB]
,[VALUE_USD]
,[QUANTITY_ACCUMULATE]
,[VALUE_THB_ACCUMULATE]
,[VALUE_USD_ACCUMULATE]
FROM [mocdtn_share].[dbo].[IMEX_HS_F_imPORT] )a
where month in ('2015') group by hs_no,month,country_code) b
order by hs_no asc,value_usd desc
|
ประวัติการแก้ไข 2016-06-24 13:34:43
 |
 |
 |
 |
Date :
2016-06-24 13:32:55 |
By :
bkawngog |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|