Hacker News new | ask | show | jobs
by mattmanser 2345 days ago
So I made something similar to this at a couple of my jobs. We could basically add a SQL script as a file to a folder and it would automatically have a new report, downloadable, formatted, run on-demand. Even a pretty basic one is pretty handy, as they only take a day or two. I hadn't got round to adding variables, I like the solution.

One of the things I added is that you could add column formatting in the field names, so a $c would turn it into a currency field, there was one to turn it into boolean checkbox, etc.:

    SELECT o.amount, p.price [price$c], p.price * o.amount [total$c]
    FROM orders o
    JOIN products p
It had other features too like you could set column widths by using @ like [amount@75] or even column grouping by dot notation [online.sales], [online.total_value$c], [instore.sales], [instore.total_value$c].
1 comments

It does basic left/right aligning for strings/numbers etc.

It's a nice feature/idea but I'm torn between implementing it and also allowing you to do it in SQL...

I agree that concat('$', table.amount) as amount should be right aligned, but mine would leave it left aligned (as it became a string).