Knocks/BackEnd/Knoks.Operate/Stored Procedures/BO_Currencies.sql

16 lines
845 B
SQL

CREATE PROCEDURE [BO_Currencies]
@Currency nvarchar(255) = NULL
AS
SELECT Symbol Code, Symbol CurrencyName, SymbolDescription LongName,
Decimals from [Symbols] where isnull(@Currency, '') = '' or SymbolDescription like '%' + @Currency + '%'
UNION ALL
SELECT t.Base Code, t.Base CurrencyName, t.Base LongName, 8 Decimals
from [Tickers] t left join [Symbols] s on s.Symbol=t.Base where s.Symbol is null and (isnull(@Currency, '') = '' or t.Base like '%' + @Currency + '%') Group by t.Base
UNION ALL
SELECT t.NonBase Code, t.NonBase CurrencyName, t.NonBase LongName, 8 Decimals
from [Tickers] t left join [Symbols] s on s.Symbol=t.NonBase
left join [Tickers] b on b.Base = t.NonBase where s.Symbol is null and b.Base is null
and (isnull(@Currency, '') = '' or t.NonBase like '%' + @Currency + '%') Group by t.NonBase
RETURN 0