Yet another SQL Server enthusiast

2017-08-08

SQL Server charts – A simple solution

Filed under: Uncategorized — sa @ 4:31 PM

A really simple and quick solution to create charts with SQL Server is to REPLICATE following two Unicode chars: 9733 ★ and 9734 ☆.

Example:

SELECT *, REPLICATE(NCHAR(9733), Sales) + REPLICATE(NCHAR(9734), MAX(Sales) OVER() - Sales) AS Chart
FROM (VALUES 
 ('Alfa Romeo', 4),
 ('Audi', 2),
 ('BMW', 1),
 ('Citroen', 4),
 ('Dacia', 10)
) AS t(Car, Sales)

sql.server.t-sql.charts.stars

Reference: https://blog.crossjoin.co.uk/2017/08/04/obscure-mdx-month-recreating-the-star-ratings-measure-in-mdx-using-excel-functions/

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: