Book a Demo

Author Topic: Custom SQL Chart  (Read 7085 times)

brback

  • EA User
  • **
  • Posts: 21
  • Karma: +1/-0
    • View Profile
Custom SQL Chart
« on: October 07, 2016, 01:53:46 am »
Hi everybody.

This is my first post to this forum, I am hoping to get some help with an issue I've been struggling with.

I have a number of packages which contains a different number of components (objects). I want to make a chart which counts the number of objects and groups them by each package. I've made a custom SQL in hope to achieve this;

Code: [Select]
SELECT t_object.Status AS Series, t_package.Name AS GroupName
FROM t_object
INNER JOIN t_package
ON t_object.Package_ID = t_package.Package_ID
WHERE t_package.Name = 'Package 1' OR
t_package.Name = 'Package 2'

This seems to be returning more or less nothing as I get no error, but a blank chart. Does anyone have any suggestions on how to solve my problem?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Custom SQL Chart
« Reply #1 on: October 07, 2016, 06:50:08 am »
I never have created a chart, but this returns just the N times (N = number of elements in according packages) the name of the package and the object status. As input for a chart that seems worthless.

q.

brback

  • EA User
  • **
  • Posts: 21
  • Karma: +1/-0
    • View Profile
Re: Custom SQL Chart
« Reply #2 on: October 07, 2016, 07:21:53 pm »
It's worthless yes, do you have any suggestions on how to fix it? :)

By choosing t_object.Status as Series I intended to get the number of different statuses for each object in each package as well, I see i forgot to mention that in my last post.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Custom SQL Chart
« Reply #3 on: October 07, 2016, 07:39:09 pm »
I'm no SQL expert, so counting things this way is not my expertise. Might be possible, but I would use scripting to solve this for me in a minute or two :-)

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Custom SQL Chart
« Reply #4 on: October 10, 2016, 09:25:49 am »
The chart creation will automatically count the rows (sum if returning ChartValue) returned matching a particular chart value. So qwerty's results mean that it should produce an interesting chart.

The same chart can also be expressed as
Code: [Select]
SELECT t_object.Status AS Series, t_package.Name AS GroupName, count(*) AS ChartValue
FROM t_object
INNER JOIN t_package
ON t_object.Package_ID = t_package.Package_ID
WHERE t_package.Name = 'Package 1' OR
t_package.Name = 'Package 2'
group by t_object.Status, t_package.Name

Both are supported because not everyone is comfortable writing more complex sql.

The only reason I can think that you would get a blank chart is that your sql doesn't return any rows.

brback

  • EA User
  • **
  • Posts: 21
  • Karma: +1/-0
    • View Profile
Re: Custom SQL Chart
« Reply #5 on: October 14, 2016, 10:30:01 pm »
Your code solved my problem, thank you Simon!  :)