Master-detail report with single SQL query?

Stimulsoft Reports.NET discussion
Post Reply
Feko
Posts: 4
Joined: Wed Apr 22, 2015 6:22 pm

Master-detail report with single SQL query?

Post by Feko »

Hello,

I'm trying to achieve something that I don't even know if is possible.
In my Data Source, I have a SQL query that returns states and their cities, just like this:

SELECT STATE_NAME, CITY_NAME FROM VIEWCITIES
----------------------------------------------------------------
CALIFORNIA - San Francisco
CALIFORNIA - San Clemente
CALIFORNIA - Santa Monica
CALIFORNIA - Santa Maria
COLORADO - Colorado Springs
COLORADO - Denver
COLORADO - Fort Morgan

And I would like to create a master-detail report, being state name the master detail and city name as sub detail, but using only that query...

CALIFORNIA
- San Francisco
- San Clemente
- Santa Monica
- Santa Maria

COLORADO
- Colorado Springs
- Denver
- Fort Morgan

Is it possible? If so, how can I do it?
Thanks in advice!
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Re: Master-detail report with single SQL query?

Post by Jan »

Hello,

Yes it possible. You can use GroupHeaderBand. Place it before DataBand. Set expression of the GroupHeaderBand to following:

Code: Select all

{YourDataSource.STATE_NAME.Substring(0, YourDataSource.STATE_NAME.IndexOf(" -"))}
After then place on GroupHeaderBand text box component with same expression.

At DataBand place textbox with following expression:

Code: Select all

{YourDataSource.STATE_NAME.Substring(YourDataSource.STATE_NAME.IndexOf(" -"))}
That's all.

Thank you.
Feko
Posts: 4
Joined: Wed Apr 22, 2015 6:22 pm

Re: Master-detail report with single SQL query?

Post by Feko »

THAT EASY???
Damn... I feel really dumb right now...
Thanks Jan, it works!! :D
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Master-detail report with single SQL query?

Post by Alex K. »

Hello,

Let us know if you need any additional help.

Thank you.
Post Reply