If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
Some additional information on your data structure and requirements would help.
Assuming your data is in a table with a date and a value, e.g.:
table myTable (
theDate date,
theValue integer);
and you want to generate a result set with the sum of the values that fall within the given months, you could use:
select
jandata.total "Jan", febdata.total "Feb", mardata.total "Mar", aprdata.total "Apr", ...
from
(select sum(theValue) total from myTable where theDate >= '01/01/2009' and theDate < '02/01/2009') jandata,
(select sum(theValue) total from myTable where theDate >= '02/01/2009' and theDate < '03/01/2009') febdata,
(select sum(theValue) total from myTable where theDate >= '03/01/2009' and theDate < '04/01/2009') mardata,
...
This is brute force, but doesn’t require any PL/SQL or unions.
(Above is in Transact-SQL, in Oracle you would need to cast the dates using the “to_date” function.)
From database table you access months in Data Table object
by using query
" SELECT * FROM tableMonth"
then catch in DataTable object of ADO.net
public DataTable SelectPeron(int Pid)
{ DataTable tab = new DataTable();
string Con = @"Data Source=sureit44;Initial Catalog=MydataBase;Persist Security Info=True;User ID=sitdev;Password=sitdev1";
using (SqlConnection con = new SqlConnection(Con))
{
string query="Select * FROM tableMonth";
SqlCommand cmd = new SqlCommand(query, con);
con.Open();
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
da.Fill(tab);
con.Close();
}
return tab;
After that Bind the tab object With DropDownList
ddl.DataSource=tab;
ddl.DataBind();
I think this will help you and u will get your d -zire result
Thanks
Some additional information on your data structure and requirements would help.
Assuming your data is in a table with a date and a value, e.g.:
table myTable (theDate date,
theValue integer);
and you want to generate a result set with the sum of the values that fall within the given months, you could use:
selectjandata.total "Jan", febdata.total "Feb", mardata.total "Mar", aprdata.total "Apr", ...
from
(select sum(theValue) total from myTable where theDate >= '01/01/2009' and theDate < '02/01/2009') jandata,
(select sum(theValue) total from myTable where theDate >= '02/01/2009' and theDate < '03/01/2009') febdata,
(select sum(theValue) total from myTable where theDate >= '03/01/2009' and theDate < '04/01/2009') mardata,
...
This is brute force, but doesn’t require any PL/SQL or unions.
(Above is in Transact-SQL, in Oracle you would need to cast the dates using the “to_date” function.)
I guess he wants to select the month names to populate a list box.
january
february
march
…
Bizarre – why no union, which would make that trivial?
With those constraints, I think you are correct that the only solution is a table of month names.
From database table you access months in Data Table object
by using query
public DataTable SelectPeron(int Pid)
{
DataTable tab = new DataTable();string Con = @"Data Source=sureit44;Initial Catalog=MydataBase;Persist Security Info=True;User ID=sitdev;Password=sitdev1";
using (SqlConnection con = new SqlConnection(Con))
{
string query="Select * FROM tableMonth";
SqlCommand cmd = new SqlCommand(query, con);
con.Open();
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
da.Fill(tab);
con.Close();
}
return tab;
After that Bind the tab object With DropDownList
> without using pl/sql
t-sql
>and less union
one union
^-))
I just realized that it has similatiry with the one provided by Mr. Msi777.
Good job, Cyberloco