DISTINCT using Query Language

4,157 views
Skip to first unread message

Dan

unread,
Nov 17, 2011, 7:07:30 AM11/17/11
to google-visua...@googlegroups.com
Hi,

I want to make a pie chart with the contents being a distinct of one column in a MSSQL database.
Is there an easy way to run an SQL distinct using the Query Language?

Thanks,
Dan

Roni Biran

unread,
Nov 17, 2011, 7:17:21 AM11/17/11
to google-visua...@googlegroups.com
there is no connectivity to the SQLServer directly. you can however create a web service that will result with a specific google charts datatable format.


--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-visualization-api/-/-lROFe8Y1fUJ.
To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.

Dan

unread,
Nov 17, 2011, 7:22:13 AM11/17/11
to google-visua...@googlegroups.com
Yes I've already setup a servlet so I can use the Query Language to query the database.
My question / request is how to do a distinct query using the google visualisation query language.

Thanks,
Dan

Roni Biran

unread,
Nov 17, 2011, 7:25:51 AM11/17/11
to google-visua...@googlegroups.com
you can select and group by to achieve this purpose.
here is the documentation for this in the query language: 

Thanks,
Dan

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.

Dan

unread,
Nov 17, 2011, 7:57:26 AM11/17/11
to google-visua...@googlegroups.com
Thanks for your help but I can't seem to get this working.

select COL1, count(COL1) where COL2="X" group by COL1

Was hoping that this would be the equivalent to distinct but instead returns the following error:
Column [COL1] cannot be selected both with and without aggregation in SELECT.

Roni Biran

unread,
Nov 17, 2011, 9:13:42 AM11/17/11
to google-visua...@googlegroups.com
this means that you cannot select and count the same column.
try selecting the following:

select COL1, count(COL2) where COL2="X" group by COL1

if it does not help, here is a sample http://jsfiddle.net/TheNez101/pKjDa/


--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.

Dan

unread,
Nov 17, 2011, 9:37:10 AM11/17/11
to google-visua...@googlegroups.com
Thanks alot Nez.

Had some lunch and with it some clarity. Wasn't obvious to me this morning to use a column which will be unique to count up number of occurrences in another column. All working now.
Reply all
Reply to author
Forward
0 new messages