|
Add a WHERE clause before the GROUP BY statement:
SELECT date, avg(amount)
FROM COTABLE
WHERE amount>0
GROUP BY date;
I hope it helps,
Marc Soleda.
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
thanks a lot for your answers.
Rgds
theepa
|
|
|
|
|
how do i generate cumulative aggregate queries in transact-sql
|
|
|
|
|
Hi!!!!
U can Enjoy with this.....
http://msdn.microsoft.com/library/default.asp?url=/library/en-s/tsqlref/ts_fa-fz_9yuk.asp
Regrads
Shashank
under2811@yahoo.co.in
|
|
|
|
|
Help!
Can anybody show me the connection string required or point me to a link regarding this matter.
I need the public to connect to a Data Acces Page on a Web Site where the database is stored on a seperate folder.
I believe this is 3 tier connection and probibly RDS?
The ISP has provided a DSN name for DSN connection as well.
Many thanks
|
|
|
|
|
kindkirk wrote: Can anybody show me the connection string required or point me to a link regarding this matter
You mean your going to open your SQL server for anyone to connect to? That’s a huge security risk, even if its password protected.
Here is a link to ADO connection strings.
ADO Connection Strings[^]
DEBUGGING : Removing the needles from the haystack.
|
|
|
|
|
Try this, it's so cool!
http://www.connectionstrings.com[^]
I always go there to look for that SQL Server connection string I can never learn!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
Luis Alonso Ramos wrote: Try this, it's so cool!
http://www.connectionstrings.com[^]
Luis, thanks for the link! Very cool...
Just like your self I can never remember the connection strings even though most of the code I write is database concentric.
DEBUGGING : Removing the needles from the haystack.
|
|
|
|
|
Hi,
I'm working on a VB6 solution that's using two access databases. One "local" database that is always accessible, located in the same folder as the application and another "remote" database that could reside either on the same computer or on a network drive. At the start-up of my application I have to open the local database and read in some settings. It all works great but here's the problem: If I unplug the internet cable from the computer I get the following error trying to open the local database -- Error 3028: "Can't start your application. The system database is missing or opened exclusively another user." What is really puzzling is that the local database has nothing to do with the remote one (which may be located on a network drive that may be disconnected by removing the network cable) and yet it doesn't let me open it.
In my code I'm using DAO methods to open the database in non-exclusive mode such as:
<code>
Dim db as Database
db = OpenDatabase("",False,False,";DATABASE='C:\Work\MyProject\local.mdb'; PWD='passcode'")
</code>
This happens running on a Windows NT 4.0 Workstation.. does naybody have any ideas what might be causing this and if you do.. how can I get around it?
Thanks for any info you might have/share
Mikk
-- modified at 17:22 Monday 17th October, 2005
|
|
|
|
|
mikanu wrote: If I unplug the internet cable from the computer I get the following error trying to open the local database -- Error 3028: "Can't start your application. The system database is missing or opened exclusively another user." What is really puzzling is that the local database has nothing to do with the remote one (which may be located on a network drive that may be disconnected by removing the network cable) and yet it doesn't let me open it.
In my code I'm using DAO methods to open the database in non-exclusive mode such as:
Dim db as Databasedb = OpenDatabase("",False,False,";DATABASE='C:\Work\MyProject\local.mdb'; PWD='passcode'")
This happens running on a Windows NT 4.0 Workstation.. does naybody have any ideas what might be causing this and if you do.. how can I get around it?
Where is the system database located? This maybe causing the problem, if it’s on a network share and there is a loss of network connectivity. A quick search of the MSDN indicates this error code is security – system db related.
You might try specifying a local system database before opening the database.
DAO Error 3028[^]
DAO error 3028 may occur when you try to create a workspace DAO object [^]
DEBUGGING : Removing the needles from the haystack.
|
|
|
|
|
Thanks for the reply! Actually, I did search MSDN for this error but that didn't clear it anymore.
Your statement is intresting though:
sfdougl wrote: Where is the system database located? This maybe causing the problem, if it’s on a network share and there is a loss of network connectivity
yet I don't understand why it would be a problem: The system database thata I'm using is the default that access is using, that is located in C:\Windows\System32\system.mdw... which is not on a network share... at least is shouldn't be... it's local, on my hard drive. It's really weired.
So, if the system.mdw is in my windows folder... any ideas why I may be getting that 3028 error? (The file is there, it's not read only.. it doesn't appear to be opened by anybody... and MS Access itself is able to open the database without yelding an error) Any ideas will be greatly appreciated!!!
|
|
|
|
|
mikanu wrote: Any ideas will be greatly appreciated!!!
I know ADO fairly well and have forgotten just about everything related to DAO so not sure I can be of much help, but here goes.
Are you using Access permissions? Or just a plain simple database password?
I think the problem my be related to how your opening a connection to the db. Check out this MSDN link for opening a connection to the db. As memory servers if you don’t open the db correctly you will get flaky behavior.
OpenDatabase Method[^]
DEBUGGING : Removing the needles from the haystack.
|
|
|
|
|
I'll check it out... Thanks!
I figured it must be related to the open database process since it's the first db-related operation in my code and it fails. The question remains: How can I tell VB to create a workspace for me and specify the fisical location of the .mdw file... guess I'll have to dig deeper!
Thanks again!
|
|
|
|
|
mikanu wrote: I figured it must be related to the open database process since it's the first db-related operation in my code and it
try the methods provided by the MSDN, I cant dig any deeper as my dev computer is boxed up waiting to be moved...
DEBUGGING : Removing the needles from the haystack.
|
|
|
|
|
How to import XML file in SQL Server using OPENXML?
I have XML file of 12MB size, containing whole database data & structure, but I can't paste it as a string in the SQL query. How to parse it to OPENXML function, to create database structure and to insert rowsets?
thanks.
|
|
|
|
|
|
I'm programming a windows form, and part of it is getting data from a SQL database, organizing it, and then displaying it. Short version of my question: How do I "refresh" the datagrid, dataview, or datatable such that changes to the datatable will be reflected in the datagridview that the user sees?
Long question:
He're's a dumbed down version of my code, with really obvious function names;
form_onLoad()
{
CrazyDataSet myDataSet;
DataView myView;
FillDataSetFromSQL();
FillCustomTable(); //the one that's going to be displayed.
myView = new DataView(myDataSet.ViewTable);
myView.rowFilter = someFilter();
myDataGridView.DataSource = myView;
}
buttonAddRow_onClick
{
AddRowToDataTable(row)
////HERE!!!
}
What do I do ^ there to have the new row show up in the datagridview? I know the dgv has refresh(), but the dataView is still unchanged, even though the datatable is not. Any suggestions? I googled and found dataView.dataBind, but it was from an article that was 3 years old and for the old DataGrid class.
|
|
|
|
|
private void RefreshGrid()
{
if (this.dataGridAllocation != null && this.dataTable != null)
{
CurrencyManager currencyManager = (CurrencyManager) this.dataGrid.BindingContext[this.dataTable];
if (currencyManager != null)
{
currencyManager.Refresh();
}
}
}
You can also do
datatable.AcceptChanges()
dataGrid.Refresh()
|
|
|
|
|
Hi Friend,
I am using early binding for getting the data from the store procedure in C++ COM DLL. All the data bind properly expect boolean value. I am doing
{
ADO_FIXED_LENGTH_ENTRY(5,ADODB::adBoolean,_rsFlag,_rsFlagStatus,FALSE)
BOOL rsFlag;
ULONG rsFlagStatus;
}
can you please help me in getting proper boolean value from store procedure.
Thanks
|
|
|
|
|
I have been given a Product table whoes all column types are varchar(8000)
One of the column is Price and other is DecimalPosition. Price column includes price without any decimal place and the data in DecimlaPosition column determins where the decimal should be placed.
So for instance, if the Price column includes '1000' and DecimalPosision includes '2' >> then it means that the actual price for this product is '10.00' and NOT '1000'. Similarly, if the DecimalPosision includes '3' >> then it means that the actual price for this product is '1.000' and NOT '1000'
My question is that when I am getting the price for a product from this table, how can I get the price in the correct format, e..g like '10.00' and not '1000'
Should I use SQL statements to convert 1000 into 10.00 or should I use some sort of programming logic to convert 1000 into 10.00.
kind regards
|
|
|
|
|
You can do it at both places. But its better to do this is a VIEW in the database. This way you avoid bugs. Hope this helps.
CREATE TABLE dbo.ctm
(
Precision varchar(32) NULL,
Val varchar(20) NULL
)
Insert ctm Values('1234567', '1')
Insert ctm Values('1234', '2')
Insert ctm Values('123456', '3')
Insert ctm Values('123456789', '4')
select convert (float,Val)/ POWER(10,convert (float,Precision)) from ctm
Use POW instead of POWER if you are not using sybase.
|
|
|
|
|
I have an access table that has a column called "ItemLink" and is of the type "Hyperlink." When I query this table and select this field, I get the display text of the hyperlink and not the url. How do I get the URL from this field in a query?
|
|
|
|
|
Please show me the steps of how to ocnfigure the MySQL database in windows XP platform?
beginner programmer..
|
|
|
|
|
Hi,
Does anyone knows how to remove the additional row that appeared at the end of the datagrid? I knew I can do that by setting the datagrid to read-only. But that is not my intention. I need to edit the cell in the datagrid. That's why I cannot set it to read-only.
Thanks,
kk
|
|
|
|
|
string connString = @"Provider=Microsoft.JET.OLEDB.4.0;data source=C:\northwind.mdb";
string sqlString = "SELECT * FROM customers";
// Connection object
OleDbConnection connection = new OleDbConnection(connString);
// Create data adapter object
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(sqlString, connection);
// Create a dataset object and fill with data using data adapter's Fill method
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet, "customers");
// Attach dataset's DefaultView to the datagrid control
dataGrid1.DataSource = dataSet.Tables["customers"];
//no adding of new rows thru dataview...
CurrencyManager cm = (CurrencyManager)this.BindingContext[dataGrid1.DataSource, dataGrid1.DataMember];
((DataView)cm.List).AllowNew = false;
|
|
|
|