Showing posts with label filled. Show all posts
Showing posts with label filled. Show all posts

Monday, March 26, 2012

parent child, display as follows - possible with SQL?

Hi there, I would like to accomplish the following, I have a table as follows:

cat_id
parent_id
cat_descr

------
Table filled as:
1, 0, Root
2, 1, Computer
3, 2, Harddisk
4, 2, Floppy drive

I would like to get a display as of:

Root
Root > Computer
Root > Computer > Harddisk
Root > Computer > Floppy drive

Thanks!yes it's possible

you need three queries in a union
select l1.cat_descr as category1
, '>'
, l2.cat_descr as category2
, '>'
, l3.cat_descr as category3
from yourtable l1
inner
join yourtable l2
on l1.cat_id = l2.parent_id
inner
join yourtable l3
on l2.cat_id = l3.parent_id
union all
select l1.cat_descr
, '>'
, l2.cat_descr
, ' '
, ' '
from yourtable l1
inner
join yourtable l2
on l1.cat_id = l2.parent_id
union all
select l1.cat_descr
, ' '
, ' '
, ' '
, ' '
from yourtable l1
order by 1,2,3,4,5|||In general you have to use recursion (Oracle "connect by", DB2/MS SQL Server Yukon - "with")

DB2 example (I added a limit by level, remove if not needed):

with
yourtable(cat_id, parent_id, cat_descr) as (values (1, 0, 'Root'), (2, 1, 'Computer'), (3, 2, 'Harddisk'), (4, 2, 'Floppy drive'))
, tree(level, id, value) as
(
select 1, cat_id, cast(cat_descr as varchar(100)) from yourtable where parent_id = 0
union all
select t2.level+1, t1.cat_id, t2.value || '>' || t1.cat_descr
from
yourtable t1, tree t2
where t1.parent_id = t2.id
and t2.level < 10
)
select value
from tree
order by level

OUTPUT:

VALUE
--------
Root
Root>Computer
Root>Computer>Harddisk
Root>Computer>Floppy drive

Monday, March 12, 2012

Parameters to reports that only show is previous parameters filled

I don't know if I can do this with Reporting Services. I have ten parameters to a stored procedure. However, each parameter only shows when the previous one is selected. For sake of this discussion, the queries from which the parameters come are completly unrelated.
Initially, only the pull-down for parameter 1 appears. When the user selects a value for parameter 1 using the initial pull-down, the pull down for parameter 2 should appear. When the user selects a value from this pull down, a pull down from parameter 3 should appear.
At any point, the user can click View Report and pass the parameters he selected and all other parameters null.
Thanks in advance for any help.
JustinYes, RS supports sequenced parameter prompting. You build the valid values
query for a parameter using a query that includes previously selected
parameter values. I believe there is a sample called 'Product Line Sales'
that illustrates this technique.
--
Brian Welcker
Group Program Manager
SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"Justin30519" <Justin30519@.discussions.microsoft.com> wrote in message
news:01FC2CE7-C435-47EC-AD00-E2762510E522@.microsoft.com...
>I don't know if I can do this with Reporting Services. I have ten
>parameters to a stored procedure. However, each parameter only shows when
>the previous one is selected. For sake of this discussion, the queries from
>which the parameters come are completly unrelated.
> Initially, only the pull-down for parameter 1 appears. When the user
> selects a value for parameter 1 using the initial pull-down, the pull down
> for parameter 2 should appear. When the user selects a value from this
> pull down, a pull down from parameter 3 should appear.
> At any point, the user can click View Report and pass the parameters he
> selected and all other parameters null.
> Thanks in advance for any help.
> Justin
>|||> Yes, RS supports sequenced parameter prompting. You build the valid values
> query for a parameter using a query that includes previously selected
> parameter values. I believe there is a sample called 'Product Line Sales'
> that illustrates this technique.
>
Thank you very much for your reply. It was helpful. I can do what my boss asked now. :)
Justin

Wednesday, March 7, 2012

Parameters Grayed Out

I have a parameter that is grayed out. Once all the parameters before it are
filled in then the gray goes away. What is causing this and how can it be
corrected.It means the greyed parameter is dependent on the earlier parameters.
check the parameters in the where condition of the query in the earlier
paramters.
Amarnath
"retkow" wrote:
> I have a parameter that is grayed out. Once all the parameters before it are
> filled in then the gray goes away. What is causing this and how can it be
> corrected.

Parameters from Dropdownlist

In SSRS 2000 how can I have the parameter filled in the drop downlist from
the database table? My query is: I want the city field filled in from the
column. Thanks in advance.
SELECT FNAME, LNAME, .EMAIL, .PHONE_NBR, CITY
FROM MR_MEMBER_1
WHERE (MEMBER_STATUS = 'A') AND (CITY = @.CITY)Go into you parameter and check the box that says "From Query" then choose
the dataset you want to use and then choose the from the value field list
the field that you want to run the parameter off of! Hope that helps...
"Shan Afzal" <Shan Afzal@.discussions.microsoft.com> wrote in message
news:89935558-78A2-441D-A410-A7C51E056189@.microsoft.com...
> In SSRS 2000 how can I have the parameter filled in the drop downlist from
> the database table? My query is: I want the city field filled in from
> the
> column. Thanks in advance.
> SELECT FNAME, LNAME, .EMAIL, .PHONE_NBR, CITY
> FROM MR_MEMBER_1
> WHERE (MEMBER_STATUS = 'A') AND (CITY = @.CITY)|||Go into you parameter and check the box that says "From Query" then choose
the dataset you want to use and then choose the from the value field list
the field that you want to run the parameter off of! Hope that helps...
"Shan Afzal" <Shan Afzal@.discussions.microsoft.com> wrote in message
news:89935558-78A2-441D-A410-A7C51E056189@.microsoft.com...
> In SSRS 2000 how can I have the parameter filled in the drop downlist from
> the database table? My query is: I want the city field filled in from
> the
> column. Thanks in advance.
> SELECT FNAME, LNAME, .EMAIL, .PHONE_NBR, CITY
> FROM MR_MEMBER_1
> WHERE (MEMBER_STATUS = 'A') AND (CITY = @.CITY)|||Ben, It gives me the follwoing error when I do what you explained.
The report parameter â'CITYâ' has a DefaultValue or a ValidValue that depends
on the report parameter â'CITYâ'. Forward dependencies are not valid.
Build complete -- 1 errors, 0 warnings
Thanks
"Ben Watts" wrote:
> Go into you parameter and check the box that says "From Query" then choose
> the dataset you want to use and then choose the from the value field list
> the field that you want to run the parameter off of! Hope that helps...
> "Shan Afzal" <Shan Afzal@.discussions.microsoft.com> wrote in message
> news:89935558-78A2-441D-A410-A7C51E056189@.microsoft.com...
> > In SSRS 2000 how can I have the parameter filled in the drop downlist from
> > the database table? My query is: I want the city field filled in from
> > the
> > column. Thanks in advance.
> >
> > SELECT FNAME, LNAME, .EMAIL, .PHONE_NBR, CITY
> > FROM MR_MEMBER_1
> > WHERE (MEMBER_STATUS = 'A') AND (CITY = @.CITY)
>
>|||You could try and create a different dataset that is exactly the same as
your current one and name it city parameter or something like that. Then
inside your report parameter for the values, change the dataset to the one
you just created and choose the field from that! Let me know.....
"Shan Afzal" <ShanAfzal@.discussions.microsoft.com> wrote in message
news:3A6CE6FD-1BEA-459C-B223-B9B3952782CE@.microsoft.com...
> Ben, It gives me the follwoing error when I do what you explained.
> The report parameter 'CITY' has a DefaultValue or a ValidValue that
> depends
> on the report parameter "CITY". Forward dependencies are not valid.
> Build complete -- 1 errors, 0 warnings
> Thanks
> "Ben Watts" wrote:
>> Go into you parameter and check the box that says "From Query" then
>> choose
>> the dataset you want to use and then choose the from the value field list
>> the field that you want to run the parameter off of! Hope that helps...
>> "Shan Afzal" <Shan Afzal@.discussions.microsoft.com> wrote in message
>> news:89935558-78A2-441D-A410-A7C51E056189@.microsoft.com...
>> > In SSRS 2000 how can I have the parameter filled in the drop downlist
>> > from
>> > the database table? My query is: I want the city field filled in from
>> > the
>> > column. Thanks in advance.
>> >
>> > SELECT FNAME, LNAME, .EMAIL, .PHONE_NBR, CITY
>> > FROM MR_MEMBER_1
>> > WHERE (MEMBER_STATUS = 'A') AND (CITY = @.CITY)
>>|||Got it Ben. Work like a champ. Thanks for your help.
"Ben Watts" wrote:
> You could try and create a different dataset that is exactly the same as
> your current one and name it city parameter or something like that. Then
> inside your report parameter for the values, change the dataset to the one
> you just created and choose the field from that! Let me know.....
> "Shan Afzal" <ShanAfzal@.discussions.microsoft.com> wrote in message
> news:3A6CE6FD-1BEA-459C-B223-B9B3952782CE@.microsoft.com...
> > Ben, It gives me the follwoing error when I do what you explained.
> >
> > The report parameter 'CITY' has a DefaultValue or a ValidValue that
> > depends
> > on the report parameter "CITY". Forward dependencies are not valid.
> > Build complete -- 1 errors, 0 warnings
> >
> > Thanks
> >
> > "Ben Watts" wrote:
> >
> >> Go into you parameter and check the box that says "From Query" then
> >> choose
> >> the dataset you want to use and then choose the from the value field list
> >> the field that you want to run the parameter off of! Hope that helps...
> >>
> >> "Shan Afzal" <Shan Afzal@.discussions.microsoft.com> wrote in message
> >> news:89935558-78A2-441D-A410-A7C51E056189@.microsoft.com...
> >> > In SSRS 2000 how can I have the parameter filled in the drop downlist
> >> > from
> >> > the database table? My query is: I want the city field filled in from
> >> > the
> >> > column. Thanks in advance.
> >> >
> >> > SELECT FNAME, LNAME, .EMAIL, .PHONE_NBR, CITY
> >> > FROM MR_MEMBER_1
> >> > WHERE (MEMBER_STATUS = 'A') AND (CITY = @.CITY)
> >>
> >>
> >>
>
>