Wednesday, March 21, 2012

DataSet . . .?

For the my report in dataset i am using union. For example:
select * from tblOne
Union All
select * from tblTwo
Union All
select * from tblThree
Union All
select * from tblFour
But when i view the report it shows in different group order
select * from tblOne
Union All
select * from tblTwo
Union All
select * from tblFour
Union All
select * from tblThree
What do i need to do, so the way i wrote the code that i would like to see
groups?
Each select statement has column with group name.
Thanks.something like: (?)
select 'one' as GroupName, * from tblOne
Union All
select 'two' as GroupName, * from tblTwo
Union All
select 'four' as GroupName, * from tblFour
Union All
select 'three' as GroupName, * from tblThree
"GGill" <GGill@.discussions.microsoft.com> wrote in message
news:822E4C84-A22B-456C-AA23-3A14C122197D@.microsoft.com...
> For the my report in dataset i am using union. For example:
> select * from tblOne
> Union All
> select * from tblTwo
> Union All
> select * from tblThree
> Union All
> select * from tblFour
> But when i view the report it shows in different group order
> select * from tblOne
> Union All
> select * from tblTwo
> Union All
> select * from tblFour
> Union All
> select * from tblThree
> What do i need to do, so the way i wrote the code that i would like to see
> groups?
> Each select statement has column with group name.
> Thanks.|||I do not have GroupName column with one, two . . .
What i am looking for is show data the way i wrote the code. Each select, in
this case i have four has product name. So i would like to show way is in
dataset.
"Jeje" wrote:
> something like: (?)
> select 'one' as GroupName, * from tblOne
> Union All
> select 'two' as GroupName, * from tblTwo
> Union All
> select 'four' as GroupName, * from tblFour
> Union All
> select 'three' as GroupName, * from tblThree
>
> "GGill" <GGill@.discussions.microsoft.com> wrote in message
> news:822E4C84-A22B-456C-AA23-3A14C122197D@.microsoft.com...
> > For the my report in dataset i am using union. For example:
> >
> > select * from tblOne
> > Union All
> > select * from tblTwo
> > Union All
> > select * from tblThree
> > Union All
> > select * from tblFour
> >
> > But when i view the report it shows in different group order
> >
> > select * from tblOne
> > Union All
> > select * from tblTwo
> > Union All
> > select * from tblFour
> > Union All
> > select * from tblThree
> >
> > What do i need to do, so the way i wrote the code that i would like to see
> > groups?
> > Each select statement has column with group name.
> >
> > Thanks.
>|||GGill,
I think it is obvious that 'the way you wrote the code' is not going to
give you the answer you want. What JeJe was suggesting was to simply add a
user defined expression to each SELECT statement to make it sort the way you
want. Such as :
SELECT '1' as SortOrder, table1.* FROM table1
UNION ALL
SELECT '2' as SortOrder, table2.* FROM table2
UNION ALL
SELECT '3' as SortOrder, table3.* FROM table3
ORDER BY SortOrder
the field "SortOrder" doesn't need to be in your table..it is an expression.
Michael C
"GGill" wrote:
> I do not have GroupName column with one, two . . .
> What i am looking for is show data the way i wrote the code. Each select, in
> this case i have four has product name. So i would like to show way is in
> dataset.
> "Jeje" wrote:
> > something like: (?)
> > select 'one' as GroupName, * from tblOne
> > Union All
> > select 'two' as GroupName, * from tblTwo
> > Union All
> > select 'four' as GroupName, * from tblFour
> > Union All
> > select 'three' as GroupName, * from tblThree
> >
> >
> > "GGill" <GGill@.discussions.microsoft.com> wrote in message
> > news:822E4C84-A22B-456C-AA23-3A14C122197D@.microsoft.com...
> > > For the my report in dataset i am using union. For example:
> > >
> > > select * from tblOne
> > > Union All
> > > select * from tblTwo
> > > Union All
> > > select * from tblThree
> > > Union All
> > > select * from tblFour
> > >
> > > But when i view the report it shows in different group order
> > >
> > > select * from tblOne
> > > Union All
> > > select * from tblTwo
> > > Union All
> > > select * from tblFour
> > > Union All
> > > select * from tblThree
> > >
> > > What do i need to do, so the way i wrote the code that i would like to see
> > > groups?
> > > Each select statement has column with group name.
> > >
> > > Thanks.
> >