Showing posts with label couple. Show all posts
Showing posts with label couple. Show all posts

Wednesday, March 28, 2012

Grouping in Reporting services

I am pulling 200,000 + records from an AS400 database through ODBC into a report. I have a couple of questions and I am totally new to SQL Reporting Services, so I don't expect a full answer to these questions, but maybe a couple of pointers or web sites that I can view for further information.

1) One of the fields that I am pulling in are dates going back to 1988. I need to first group these dates by year. Do the expressions used in the cells of a report table allow for formulas like =date.year?

2) I have a couple of fields that I need to group on: first being year, then state. There is a numeric field (participants) that I need to do a sum on. Do the reports have a (+) next to the grouping levels so for instance I have the 2000 year "closed", I need this to show total participants during that year (for every state). If 2000 was opened then it would list each state (that could further be drilled into) that would show total participants by state. I hope this makes sense. I used to do this in Visual Basic Windows forms 2003 version using the DataView control.

Thanks for any information.

Brad

i don't know about the first one but the second bit is possible take a look at this article on how to do it

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsql2k/html/olapasandrs.asp?frame=true

Friday, March 9, 2012

Group by Stored Procedure

If I use a group by sp to group by id number, is there any way to get a couple of fields in the last entry in the table for that id number. One field is date so I can use max for that field, but how about the others. In Access you can use Last in a totals query. Is there a way to do that in sql?Can you post DDL (in the form of CREATE TABLE statments), sample data (in
the form of INSERT statements), and what sample output you're looking for?
I'm having a lot of trouble understanding your requirements from this
description and it will be easier to work with and talk about real data.
"drbobh" <drbobh@.discussions.microsoft.com> wrote in message
news:5E8ABE2B-2928-4B1D-B337-3565508DACFD@.microsoft.com...
> If I use a group by sp to group by id number, is there any way to get a
couple of fields in the last entry in the table for that id number. One
field is date so I can use max for that field, but how about the others. In
Access you can use Last in a totals query. Is there a way to do that in sql?|||It sounds like you're asking for something along these lines:
select
id_num, your_date, other_thing, something_else
from theTable T1
where your_date = (
select max(your_date)
from theTable T2
where T2.id_num = T1.id_num
)
Another way to get the result is
...
where not exists (
select * from Table T2
where T2.id_num = T1.id_num
and T2.your_date > T1.your_date
)
So it's either "get those rows where the date is the latest among all
rows with that id_num value" or "get those rows for which there is no
other row with the same id and a more recent date".
Note that if there are multiple rows with the latest date for a given
id, you will get them all, not just 1 as you would with the Access LAST
aggregate. The Access LAST function is convenient, but something like
it in SQL Server would not guarantee repeatable results and would create
more problems than it solved. I suspect LAST() depends on the order in
which the table rows are accessed, and in SQL Server, that depends on
things other than the indexes and the query.
Steve Kass
Drew University
drbobh wrote:
>If I use a group by sp to group by id number, is there any way to get a couple of fields in the last entry in the table for that id number. One field is date so I can use max for that field, but how about the others. In Access you can use Last in a totals query. Is there a way to do that in sql?
>|||> In Access you can use Last in a totals query.
> Is there a way to do that in sql?
Maybe. But what would the "last" row be if not the row with the latest date?
If you post DDL for your table and explain what you mean by "last" then we
can help you with the query.
--
David Portas
SQL Server MVP
--|||Thanks Steve for the solution and the explanation, that's what I was looking for.
"Steve Kass" wrote:
> It sounds like you're asking for something along these lines:
> select
> id_num, your_date, other_thing, something_else
> from theTable T1
> where your_date = (
> select max(your_date)
> from theTable T2
> where T2.id_num = T1.id_num
> )
> Another way to get the result is
> ...
> where not exists (
> select * from Table T2
> where T2.id_num = T1.id_num
> and T2.your_date > T1.your_date
> )
> So it's either "get those rows where the date is the latest among all
> rows with that id_num value" or "get those rows for which there is no
> other row with the same id and a more recent date".
> Note that if there are multiple rows with the latest date for a given
> id, you will get them all, not just 1 as you would with the Access LAST
> aggregate. The Access LAST function is convenient, but something like
> it in SQL Server would not guarantee repeatable results and would create
> more problems than it solved. I suspect LAST() depends on the order in
> which the table rows are accessed, and in SQL Server, that depends on
> things other than the indexes and the query.
> Steve Kass
> Drew University
> drbobh wrote:
> >If I use a group by sp to group by id number, is there any way to get a couple of fields in the last entry in the table for that id number. One field is date so I can use max for that field, but how about the others. In Access you can use Last in a totals query. Is there a way to do that in sql?
> >
> >
>

Group by Stored Procedure

If I use a group by sp to group by id number, is there any way to get a couple of fields in the last entry in the table for that id number. One field is date so I can use max for that field, but how about the others. In Access you can use Last in a totals
query. Is there a way to do that in sql?
Can you post DDL (in the form of CREATE TABLE statments), sample data (in
the form of INSERT statements), and what sample output you're looking for?
I'm having a lot of trouble understanding your requirements from this
description and it will be easier to work with and talk about real data.
"drbobh" <drbobh@.discussions.microsoft.com> wrote in message
news:5E8ABE2B-2928-4B1D-B337-3565508DACFD@.microsoft.com...
> If I use a group by sp to group by id number, is there any way to get a
couple of fields in the last entry in the table for that id number. One
field is date so I can use max for that field, but how about the others. In
Access you can use Last in a totals query. Is there a way to do that in sql?
|||It sounds like you're asking for something along these lines:
select
id_num, your_date, other_thing, something_else
from theTable T1
where your_date = (
select max(your_date)
from theTable T2
where T2.id_num = T1.id_num
)
Another way to get the result is
...
where not exists (
select * from Table T2
where T2.id_num = T1.id_num
and T2.your_date > T1.your_date
)
So it's either "get those rows where the date is the latest among all
rows with that id_num value" or "get those rows for which there is no
other row with the same id and a more recent date".
Note that if there are multiple rows with the latest date for a given
id, you will get them all, not just 1 as you would with the Access LAST
aggregate. The Access LAST function is convenient, but something like
it in SQL Server would not guarantee repeatable results and would create
more problems than it solved. I suspect LAST() depends on the order in
which the table rows are accessed, and in SQL Server, that depends on
things other than the indexes and the query.
Steve Kass
Drew University
drbobh wrote:

>If I use a group by sp to group by id number, is there any way to get a couple of fields in the last entry in the table for that id number. One field is date so I can use max for that field, but how about the others. In Access you can use Last in a total
s query. Is there a way to do that in sql?
>
|||> In Access you can use Last in a totals query.
> Is there a way to do that in sql?
Maybe. But what would the "last" row be if not the row with the latest date?
If you post DDL for your table and explain what you mean by "last" then we
can help you with the query.
David Portas
SQL Server MVP
|||Thanks Steve for the solution and the explanation, that's what I was looking for.
"Steve Kass" wrote:
[vbcol=seagreen]
> It sounds like you're asking for something along these lines:
> select
> id_num, your_date, other_thing, something_else
> from theTable T1
> where your_date = (
> select max(your_date)
> from theTable T2
> where T2.id_num = T1.id_num
> )
> Another way to get the result is
> ...
> where not exists (
> select * from Table T2
> where T2.id_num = T1.id_num
> and T2.your_date > T1.your_date
> )
> So it's either "get those rows where the date is the latest among all
> rows with that id_num value" or "get those rows for which there is no
> other row with the same id and a more recent date".
> Note that if there are multiple rows with the latest date for a given
> id, you will get them all, not just 1 as you would with the Access LAST
> aggregate. The Access LAST function is convenient, but something like
> it in SQL Server would not guarantee repeatable results and would create
> more problems than it solved. I suspect LAST() depends on the order in
> which the table rows are accessed, and in SQL Server, that depends on
> things other than the indexes and the query.
> Steve Kass
> Drew University
> drbobh wrote:
als query. Is there a way to do that in sql?
>

Group by Stored Procedure

If I use a group by sp to group by id number, is there any way to get a coup
le of fields in the last entry in the table for that id number. One field is
date so I can use max for that field, but how about the others. In Access y
ou can use Last in a totals
query. Is there a way to do that in sql?Can you post DDL (in the form of CREATE TABLE statments), sample data (in
the form of INSERT statements), and what sample output you're looking for?
I'm having a lot of trouble understanding your requirements from this
description and it will be easier to work with and talk about real data.
"drbobh" <drbobh@.discussions.microsoft.com> wrote in message
news:5E8ABE2B-2928-4B1D-B337-3565508DACFD@.microsoft.com...
> If I use a group by sp to group by id number, is there any way to get a
couple of fields in the last entry in the table for that id number. One
field is date so I can use max for that field, but how about the others. In
Access you can use Last in a totals query. Is there a way to do that in sql?|||It sounds like you're asking for something along these lines:
select
id_num, your_date, other_thing, something_else
from theTable T1
where your_date = (
select max(your_date)
from theTable T2
where T2.id_num = T1.id_num
)
Another way to get the result is
...
where not exists (
select * from Table T2
where T2.id_num = T1.id_num
and T2.your_date > T1.your_date
)
So it's either "get those rows where the date is the latest among all
rows with that id_num value" or "get those rows for which there is no
other row with the same id and a more recent date".
Note that if there are multiple rows with the latest date for a given
id, you will get them all, not just 1 as you would with the Access LAST
aggregate. The Access LAST function is convenient, but something like
it in SQL Server would not guarantee repeatable results and would create
more problems than it solved. I suspect LAST() depends on the order in
which the table rows are accessed, and in SQL Server, that depends on
things other than the indexes and the query.
Steve Kass
Drew University
drbobh wrote:

>If I use a group by sp to group by id number, is there any way to get a couple of f
ields in the last entry in the table for that id number. One field is date so I can
use max for that field, but how about the others. In Access you can use Last in a to
tal
s query. Is there a way to do that in sql?
>|||> In Access you can use Last in a totals query.
> Is there a way to do that in sql?
Maybe. But what would the "last" row be if not the row with the latest date?
If you post DDL for your table and explain what you mean by "last" then we
can help you with the query.
David Portas
SQL Server MVP
--|||Thanks Steve for the solution and the explanation, that's what I was looking
for.
"Steve Kass" wrote:

> It sounds like you're asking for something along these lines:
> select
> id_num, your_date, other_thing, something_else
> from theTable T1
> where your_date = (
> select max(your_date)
> from theTable T2
> where T2.id_num = T1.id_num
> )
> Another way to get the result is
> ...
> where not exists (
> select * from Table T2
> where T2.id_num = T1.id_num
> and T2.your_date > T1.your_date
> )
> So it's either "get those rows where the date is the latest among all
> rows with that id_num value" or "get those rows for which there is no
> other row with the same id and a more recent date".
> Note that if there are multiple rows with the latest date for a given
> id, you will get them all, not just 1 as you would with the Access LAST
> aggregate. The Access LAST function is convenient, but something like
> it in SQL Server would not guarantee repeatable results and would create
> more problems than it solved. I suspect LAST() depends on the order in
> which the table rows are accessed, and in SQL Server, that depends on
> things other than the indexes and the query.
> Steve Kass
> Drew University
> drbobh wrote:
>
als query. Is there a way to do that in sql?[vbcol=seagreen]
>

Sunday, February 19, 2012

GridView, XML, and .NET 2005 Application

Hello, I'm in the processing of learning .NET 2005 and an trying to rewrite
a simple command line application that I wrote a couple years ago. I have
the following requirements:
1) Read an XML file that I create with a list of .EXE and .DLL files.
2) Scan a directory based on the path stored within the XML file and extract
the production version information
3) Add the Path, Filename and version information to a GridView control.
Now I have item #3 working today which displays output to screen using
console.write.
Question 1:
How can I add headers to a datagrid and update with my own information based
on me scanning a directory?
Question 2:
My application today reads the file path information, etc., from SQL Server
and then scans the directory for the version information. I would like to
instead use an XML file to contain this information instead of SQL Server.
This way I can use ClickOnce easily deploy my application without having a
SQL Server requirement. Most of my updates will be done to the XML file
only, so I would simply like to republish my ClickOnce to have user
redownload new XML file.
What is the best way for me to create an XML file of my data that can be
maintained? I have columsn such as:
1) Filename
2) Path of file
3) Description
4) Shortname of file
Each row within the XML will be unique. I need a way that I can easily
update/create this file. I currently have about 200 rows in SQL that I need
to get into my XML file. I really do not want to retype all the
information, but I can if I have to.
Any help or direction with this would be appreciated.
You can save a DataSet as XML.
And something else you might want to think about. If the data displayed is
static, not requiring any user interaction, you might want to think about
optimizing your app by using an XSL transform to create the data in HTML in
the page, rather than a DataGrid. You can create an XSL style sheet, and use
an Xml WebControl to display it in any format you choose (as HTML).
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition
"dm1608" <dm1608@.spam.net> wrote in message
news:u3Uq5nU9FHA.1148@.tk2msftngp13.phx.gbl...
> Hello, I'm in the processing of learning .NET 2005 and an trying to
> rewrite a simple command line application that I wrote a couple years ago.
> I have the following requirements:
> 1) Read an XML file that I create with a list of .EXE and .DLL files.
> 2) Scan a directory based on the path stored within the XML file and
> extract the production version information
> 3) Add the Path, Filename and version information to a GridView control.
>
> Now I have item #3 working today which displays output to screen using
> console.write.
> Question 1:
> How can I add headers to a datagrid and update with my own information
> based on me scanning a directory?
> Question 2:
> My application today reads the file path information, etc., from SQL
> Server and then scans the directory for the version information. I would
> like to instead use an XML file to contain this information instead of SQL
> Server. This way I can use ClickOnce easily deploy my application without
> having a SQL Server requirement. Most of my updates will be done to the
> XML file only, so I would simply like to republish my ClickOnce to have
> user redownload new XML file.
> What is the best way for me to create an XML file of my data that can be
> maintained? I have columsn such as:
> 1) Filename
> 2) Path of file
> 3) Description
> 4) Shortname of file
> Each row within the XML will be unique. I need a way that I can easily
> update/create this file. I currently have about 200 rows in SQL that I
> need to get into my XML file. I really do not want to retype all the
> information, but I can if I have to.
> Any help or direction with this would be appreciated.
>
>
>
|||Thanks for the reply, Keven.
I'm trying to do away with using SQL Server. If I use the SaveToXML option
of ADO.NET, is the XML file the is created something that can easily be
maintained going forward? I guess I cannot control the output or format of
the XML file, so that is why I'm thinking it may not be what I want.
Opinions?
"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:%23WA93ra9FHA.3876@.TK2MSFTNGP09.phx.gbl...
> You can save a DataSet as XML.
> And something else you might want to think about. If the data displayed is
> static, not requiring any user interaction, you might want to think about
> optimizing your app by using an XSL transform to create the data in HTML
> in the page, rather than a DataGrid. You can create an XSL style sheet,
> and use an Xml WebControl to display it in any format you choose (as
> HTML).
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> If you push something hard enough,
> it will fall over.
> - Fudd's First Law of Opposition
> "dm1608" <dm1608@.spam.net> wrote in message
> news:u3Uq5nU9FHA.1148@.tk2msftngp13.phx.gbl...
>
|||I don't think it s a good idea to replace the database with an XML file. You
will loose all the benefits of concurrency control, backup/restore,
maintenance etc that the database provides you with.
You can store your XML in the database though either shredded (if it is
relational in nature) or natively...
Best regards
Michael
"dm1608" <dm1608@.spam.net> wrote in message
news:es1WSjb9FHA.2716@.TK2MSFTNGP11.phx.gbl...
> Thanks for the reply, Keven.
> I'm trying to do away with using SQL Server. If I use the SaveToXML
> option of ADO.NET, is the XML file the is created something that can
> easily be maintained going forward? I guess I cannot control the output
> or format of the XML file, so that is why I'm thinking it may not be what
> I want.
> Opinions?
> "Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
> news:%23WA93ra9FHA.3876@.TK2MSFTNGP09.phx.gbl...
>

GridView, XML, and .NET 2005 Application

Hello, I'm in the processing of learning .NET 2005 and an trying to rewrite
a simple command line application that I wrote a couple years ago. I have
the following requirements:
1) Read an XML file that I create with a list of .EXE and .DLL files.
2) Scan a directory based on the path stored within the XML file and extract
the production version information
3) Add the Path, Filename and version information to a GridView control.
Now I have item #3 working today which displays output to screen using
console.write.
Question 1:
How can I add headers to a datagrid and update with my own information based
on me scanning a directory?
Question 2:
My application today reads the file path information, etc., from SQL Server
and then scans the directory for the version information. I would like to
instead use an XML file to contain this information instead of SQL Server.
This way I can use ClickOnce easily deploy my application without having a
SQL Server requirement. Most of my updates will be done to the XML file
only, so I would simply like to republish my ClickOnce to have user
redownload new XML file.
What is the best way for me to create an XML file of my data that can be
maintained? I have columsn such as:
1) Filename
2) Path of file
3) Description
4) Shortname of file
Each row within the XML will be unique. I need a way that I can easily
update/create this file. I currently have about 200 rows in SQL that I need
to get into my XML file. I really do not want to retype all the
information, but I can if I have to.
Any help or direction with this would be appreciated.You can save a DataSet as XML.
And something else you might want to think about. If the data displayed is
static, not requiring any user interaction, you might want to think about
optimizing your app by using an XSL transform to create the data in HTML in
the page, rather than a DataGrid. You can create an XSL style sheet, and use
an Xml WebControl to display it in any format you choose (as HTML).
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition
"dm1608" <dm1608@.spam.net> wrote in message
news:u3Uq5nU9FHA.1148@.tk2msftngp13.phx.gbl...
> Hello, I'm in the processing of learning .NET 2005 and an trying to
> rewrite a simple command line application that I wrote a couple years ago.
> I have the following requirements:
> 1) Read an XML file that I create with a list of .EXE and .DLL files.
> 2) Scan a directory based on the path stored within the XML file and
> extract the production version information
> 3) Add the Path, Filename and version information to a GridView control.
>
> Now I have item #3 working today which displays output to screen using
> console.write.
> Question 1:
> How can I add headers to a datagrid and update with my own information
> based on me scanning a directory?
> Question 2:
> My application today reads the file path information, etc., from SQL
> Server and then scans the directory for the version information. I would
> like to instead use an XML file to contain this information instead of SQL
> Server. This way I can use ClickOnce easily deploy my application without
> having a SQL Server requirement. Most of my updates will be done to the
> XML file only, so I would simply like to republish my ClickOnce to have
> user redownload new XML file.
> What is the best way for me to create an XML file of my data that can be
> maintained? I have columsn such as:
> 1) Filename
> 2) Path of file
> 3) Description
> 4) Shortname of file
> Each row within the XML will be unique. I need a way that I can easily
> update/create this file. I currently have about 200 rows in SQL that I
> need to get into my XML file. I really do not want to retype all the
> information, but I can if I have to.
> Any help or direction with this would be appreciated.
>
>
>|||Thanks for the reply, Keven.
I'm trying to do away with using SQL Server. If I use the SaveToXML option
of ADO.NET, is the XML file the is created something that can easily be
maintained going forward? I guess I cannot control the output or format of
the XML file, so that is why I'm thinking it may not be what I want.
Opinions?
"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:%23WA93ra9FHA.3876@.TK2MSFTNGP09.phx.gbl...
> You can save a DataSet as XML.
> And something else you might want to think about. If the data displayed is
> static, not requiring any user interaction, you might want to think about
> optimizing your app by using an XSL transform to create the data in HTML
> in the page, rather than a DataGrid. You can create an XSL style sheet,
> and use an Xml WebControl to display it in any format you choose (as
> HTML).
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> If you push something hard enough,
> it will fall over.
> - Fudd's First Law of Opposition
> "dm1608" <dm1608@.spam.net> wrote in message
> news:u3Uq5nU9FHA.1148@.tk2msftngp13.phx.gbl...
>|||I don't think it s a good idea to replace the database with an XML file. You
will loose all the benefits of concurrency control, backup/restore,
maintenance etc that the database provides you with.
You can store your XML in the database though either shredded (if it is
relational in nature) or natively...
Best regards
Michael
"dm1608" <dm1608@.spam.net> wrote in message
news:es1WSjb9FHA.2716@.TK2MSFTNGP11.phx.gbl...
> Thanks for the reply, Keven.
> I'm trying to do away with using SQL Server. If I use the SaveToXML
> option of ADO.NET, is the XML file the is created something that can
> easily be maintained going forward? I guess I cannot control the output
> or format of the XML file, so that is why I'm thinking it may not be what
> I want.
> Opinions?
> "Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
> news:%23WA93ra9FHA.3876@.TK2MSFTNGP09.phx.gbl...
>