Query editor
WITHclose_details AS (SELECTcls.evt_tx_hash AS tx_hash,cls.evt_block_time AS time,des.account,CASE des.indextokenWHEN 0x82af49447d8a07e3bd95bd0d56f35241523fbab1 THEN 'WETH'WHEN 0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f THEN 'WBTC'WHEN 0xf97f4df75117a78c1a5a0dbb814af92458539fb4 THEN 'LINK'WHEN 0xfa7f8980b0f1e64a2062791cc3b0871572f1f7f0 THEN 'UNI'END AS token,IF(des.islong, 'LONG', 'SHORT') AS position_side,cls.realisedpnl / 1e30 AS pnlFROMgmx_arbitrum.vault_evt_closeposition AS clsINNER JOIN gmx_arbitrum.vault_evt_decreaseposition AS des ON cls.evt_tx_hash = des.evt_tx_hash-- WHERE des.account = 0xcb696fd8e239dd68337c70f542c2e38686849e90)selectrow_number() over (order bytotal_pnl desc) as rankings,CONCAT('<a href=https://debank.com/profile/',CAST(account AS varchar),' target=_blank>',CAST(account AS varchar),'</a>') AS account,round(total_pnl, 4) as total_pnl,win_counts,loss_counts,round(win_rate * 100, 4) as win_rate,ages,last_active_time,account as account_rawfrom(SELECTaccount,SUM(pnl) AS total_pnl,SUM(IF(pnl >= 0, 1, 0)) as win_counts,SUM(IF(pnl < 0, 1, 0)) as loss_counts,cast(SUM(IF(pnl >= 0, 1, 0)) as double) / cast(COUNT(1) as double) AS win_rate,date_diff('day', min(time), current_date) as ages,max(time) as last_active_timeFROMclose_detailsGROUP BY1)order by1limit100