How do I get a bargraph of brand counts per week

I’m rather new to grafana and I’m using it to get an overview of what brands our customers order among our items.
I’m trying to make graphs with an aggregation of the brands ordered we recieve per week in our order database. Our database is postgres and has the following relevant tables:

order table:

date_create
item_count
brand
model
(and a lot more fields)

how do I create the approprialte sql aggregrations? I can get the total number in the table

Your description is very vague - columns are not clear, table relations are also not clear. Start simple, e.g.:

SELECT
  $__timeGroupAlias(<time-column>,7d,0),
  sum(*) AS "count"
FROM <table>
WHERE
  $__timeFilter(<time-column>)
GROUP BY 1
ORDER BY 1

Then add more complexity, e.g. joins etc. Of course, doc is your friend PostgreSQL | Grafana Labs - for example to understand Grafana macros. Also use query inspector to check generated SQL.

please be friendly to new users, i totally dislike your attitude to newbies!! :frowning: !!

This topic was automatically closed after 365 days. New replies are no longer allowed.