我有一个SQL查询,在转换为Grafana格式时需要帮助。 我尝试将代码转换为Grafana,但它给了我和Unknown macro _timeEpoch错误。我不知道转换是否不正确,或者是否需要更改Grafana中的设置。
这是尝试做的事情:
request.page_size
这是SQL代码:
select
$_timeEpoch(CAST(MONTH(B.invoice_date) AS varchar(2)) + '-' + RIGHT('0' + CAST(DAY(B.invoice_date) AS varchar(2)), 2) + '-' + CAST(YEAR(B.invoice_date)AS varchar(4))),
'$'+ Format(SUM(B.total_amount), '#,00') as value
from invoice_hdr as B
join oe_pick_ticket as A on A.invoice_no = B.invoice_no
Where
$_timeFilter(invoice_date >= DATEADD(DAY, DATEDIFF(DAY, 7, GETDATE()), 0) and approved = 'Y' and (location_id = '10'
or location_id = '11'
or location_id = '12'
or location_id = '13'
or location_id = '14'
or location_id = '15'
or location_id = '20'
or location_id = '25'
or location_id = '30'
or location_id = '40'
or location_id = '50'))
GROUP by CAST(MONTH(B.invoice_date) AS varchar(2))+ '-' + RIGHT('0' + CAST(DAY(B.invoice_date) AS varchar(2)), 2) + '-' + CAST(YEAR(B.invoice_date)AS varchar(4))
Order by
CAST(MONTH(B.invoice_date) AS varchar(2))+ '-' + RIGHT('0' + CAST(DAY(B.invoice_date) AS varchar(2)), 2) + '-' + CAST(YEAR(B.invoice_date)AS varchar(4)) ASC
我需要的格式:
select CAST(MONTH(B.invoice_date) AS varchar(2)) + '-' + RIGHT('0' + CAST(DAY(B.invoice_date) AS varchar(2)), 2) + '-' + CAST(YEAR(B.invoice_date)AS varchar(4)) AS 'Invoice Date', '$'+ Format(SUM(B.total_amount), '#,00') as 'Total Amount'
from invoice_hdr as B
join oe_pick_ticket as A on A.invoice_no = B.invoice_no
Where invoice_date >= DATEADD(DAY, DATEDIFF(DAY, 7, GETDATE()), 0) and approved = 'Y' and (location_id = '10'
or location_id = '11'
or location_id = '12'
or location_id = '13'
or location_id = '14'
or location_id = '15'
or location_id = '20'
or location_id = '25'
or location_id = '30'
or location_id = '40'
or location_id = '50')
GROUP by CAST(MONTH(B.invoice_date) AS varchar(2))+ '-' + RIGHT('0' + CAST(DAY(B.invoice_date) AS varchar(2)), 2) + '-' + CAST(YEAR(B.invoice_date)AS varchar(4))
order by 'Invoice Date'