Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Databar with single value Expand / Collapse
Author
Message
Posted Tuesday, September 4, 2012 3:29 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, October 31, 2014 1:34 AM
Points: 92, Visits: 344
This is such a newbie question, but I haven't been able to figure it out. I have a databar that only appears on a single row. I will have to hardcode in my select statement what to evaluate it against. I thought I could do something like this:

SELECT value AS size
FROM table
WHERE condition = 'yes'

UNION ALL

SELECT CAST('100' AS Numeric)

The results would be:

Size
23
100

But when I put the column "size" as my value, nothing happens - the whole bar is shaded. Would someone mind pointing me in the right direction?
Post #1354218
Posted Wednesday, September 5, 2012 8:33 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, November 12, 2012 4:33 PM
Points: 24, Visits: 105
does this script work in a query window? i could be wrong but i think you might have to put an "as Size" after the cast statement.
Post #1354595
Posted Wednesday, September 5, 2012 9:24 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 9:10 AM
Points: 13,230, Visits: 12,709
Andy Gerard (9/5/2012)
does this script work in a query window? i could be wrong but i think you might have to put an "as Size" after the cast statement.


No, the two select statements are in a union. The first select statement will control the column names. If this was not the behavior then it would allow for the same column to have two different names in the same query.

Here is proof:

select 1 as MyColName union all
select 2 as SomeOther





_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1354664
Posted Wednesday, September 5, 2012 9:45 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, November 12, 2012 4:33 PM
Points: 24, Visits: 105
right, right... sorry for the bad info.
Post #1354692
Posted Wednesday, September 5, 2012 10:07 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 9:10 AM
Points: 13,230, Visits: 12,709
Andy Gerard (9/5/2012)
right, right... sorry for the bad info.


No worries.

Now to try to help the OP...I don't understand what the issue is.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1354720
Posted Wednesday, September 5, 2012 10:27 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, November 12, 2012 4:33 PM
Points: 24, Visits: 105
if i understand correctly, the OP is looking to have the values returned in the query used as Y-axis values for a bar graph. the query should return two values, (23, 100) and the graph should have 2 points on the x axis with these y axis values, but it's not working.
Post #1354730
Posted Wednesday, September 5, 2012 10:56 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, October 31, 2014 1:34 AM
Points: 92, Visits: 344
You got it. Basically, I'm not sure how to structure the query or the bar graph to make it move around. For example, I have a class that has 100 available seats but only 25 of those seats are taken. So I want to move the bar 25%. The class size (e.g. 100) will have to be hardcoded, but the seats take (e.g. 25) will come from a query. It's a newbie question, but I haven't dealt with charts much before.
Post #1354760
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse