|
Thanks, that worked! I just needed the dashes.
Lost in the vast sea of .NET
|
|
|
|
|
|
The key is time,for example, every 10 records compose a group, so
group 0: 1st 2nd ...
group 1: 11th 12th ...
group 2: 21st 22nd ...
...
Now I want to get the sum of the first record of ten continuous group, so the values are from
records: 1st 11th 21st ... 91st
Does ado/mssql support this? Because my program need performance.
Thanks very much.
|
|
|
|
|
Hi,
Can you explain the table structure, like what keys you are having on it, its columns and their datatypes, etc?
Regards,
Adeel
Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.
|
|
|
|
|
OK, essentially, it is like this
Col Name Type Length(bytes)
Time(key) datatime 8
Price real 4
|
|
|
|
|
Hi,
You are using MS SQL 2005? And are you using group by on time column and want to sum the price, am i right my friend?
Regards,
Adeel
Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.
|
|
|
|
|
I'm using MS SQL 2000, I want to get the first record every n records.
For example if every group has 10 records, then the records I want are
1,11,21,31,41,51...
Doing it manually is too slow.
|
|
|
|
|
Hi,
Hopefuly one last question, do you have prior knowledge of the groups you will be making?
I hope i am not irritating you!
Regards,
Adeel
Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.
|
|
|
|
|
No other prior knowledge of grouping.
Like the Moving Average Line in stock software, only how many records consists of a group is known when grouping.
-- modified at 3:28 Wednesday 14th November, 2007
|
|
|
|
|
Hi,
I haven't tried it, just a thought, try with the preprocessing of the data, like write a procedure/routine for knowing groups, and keep a count of each groups rows, and pick by using that count.
Second idea is, to try with a Top function, in multiple sub queries, or via partitioning.
This is tricky, because you are trying to do multi-dimentional sort of activity, on a DBMS which is not much familiar to it!
Even in MS SQL 2005, it is bit difficult, but do-able, using the ranking function with top function.
Hope this is of some help.
Regards,
Adeel
Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.
|
|
|
|
|
I just worried about the performance, now I find that a creating a temporary table would solve the problem.
Thank you all the same.
|
|
|
|
|
im looking if exist Query do this
1-back up the database into specific path,
2-restore data from specific path.
3-return all of the user tables in specific database
thx
|
|
|
|
|
|
Why does this not work.....SQL
Declare @MyParam varchar (20)
Set @MyParam = 'MyTableName'
Select * from @MyParam
Seems obvious that it should, is it all TEMP TABLES needed.
|
|
|
|
|
Where exactly are you defining a temporary table in this example?
|
|
|
|
|
Hi, I'm not.
Just want to use a variable to access an exisiting table.
Select * from @parameter
is this not possible?
Thanks for the interest
|
|
|
|
|
ASAIK, you can only create a table[^] variable, fill it with data and then use in SELECT statements.
imnotso# wrote: Just want to use a variable to access an exisiting table.
BTW, why do you want to do something like this?
|
|
|
|
|
have the sql query in a string variable and execute using sp_executesql or EXECUTE Command. something like this should work, try...
@SqlQuery = 'Select * from ' + @MyParam<br />
EXEC sp_executesql @SqlQuery
Regards - J O H N -
|
|
|
|
|
You should always enclosed the table name in side square brackets just in case it contains any odd characters and the table name should be checked to see if the table exists first. These are very basic security precautions against invalid or maliceous data from causing problems with the database.
|
|
|
|
|
Thanks John,
but
declare @SqlQuery varchar
set @SqlQuery = 'Select * from raiser wHERE raiser.raiserid=3'
EXEC @SqlQuery
Server: Msg 2812, Level 16, State 62, Line 5
Could not find stored procedure 'S'.
doesn't work
what am I doing wrong?
|
|
|
|
|
|
hi there, in this example you didn't create any table. You creating a variable and it is not possible to select from variable,
--
Declare @MyParam varchar (20)
Set @MyParam = 'MyTableName'
you can simple select like this:
SELECT @MyParam
-- it will give this result 'MyTableName'
if you want to create table, use this
Create Table #MyTableName
(
here you define the attributes
ex.
atributename varchar(20)
)
and then you can use
SELECT * FROM #MyTableName
the result --- atributename
respect
spaps
|
|
|
|
|
Cheers guys, job done via Dynamic SQL.
Why I can't lookup a variable table name, who knows? Seems stupid to not be able to.
Thanks again.
|
|
|
|
|
imnotso# wrote: Why I can't lookup a variable table name, who knows?
Because it's not part of the language specification.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi,
My aim is to bind the data dynamically to a label ..the database used is MS Access
I have created a module for creation of a database and inserting values in it through a gui n a canvas on which labels are dragged and dropped i want to print the form dynamically the process is getting values from the database n printing i know how to print but not how to bind the data i have tried with label1.databinding but failed as labels are also generated dynamically i cant bind them using properties window
if any one knows how to bind dynamically data please let me know..
regards
sindhu tiwari
its me sid
|
|
|
|