Initially there were 1000 records to evaluate.Now there are 40000.Please help!
I'm only trying to obtain the week number of a transaction based on transaction date and start date.
SELECT [1_Webtime_By_Date].Badge,Int(((([1_Webtime_By_Date].Date-Forms![Date Form].StartDate)+1.99)/7)+1) AS Week
FROM 1_Webtime_By_Date
GROUP BY [1_Webtime_By_Date].Badge,Int(((([1_Webtime_By_Date].Date-Forms![Date Form].StartDate)+1.99)/7)+1);
This is a known issue with the compiler used by Access. Limits of 64K segments were lifted after Access 97 but the amount of data you are quering is simply too much for Access. There are a few tips given on the following page that may help but it seems to me that you need to use a proper database system such as MS SQL. There is a free version available (SQL Express) if it's cost that is the problem.
ACC: "Out of Memory" or "Query Too Complex" with Query/Report
SQL Server Express Download page
You may find that using SQL Server as a database and Access as a front end may help your problems if you are tied to using Access for end users.
The best tip given is to use aliasing to shorten the length of your query and to try to remove nested queries:
Access SQL: FROM clause
My first inclination is to add some white space before and after both the minus signs.
My next test would to make the form field into a DATE type, and use something like
DATEPART(ww,[1_Webtime_By_Date].Date - Forms![Date Form].StartDate ) AS WK
In my application that using MSAccess as DB, I need to implement pagewise loading with sql query.
I know how to load first 10 records, thats by
SELECT TOP 10 * FROM Product ORDER BY dateAdded DESC
But how can I pick record that is from 10 to 20.
Any Idea?
It's possible in Access SQL, but not as straightforward as in other database products.
(for example MySQL, where it would be just LIMIT 10,10)
Check out my answer here:
How to do MS Access database paging + search?
(the code to build the SQL Statement is in C#, but of course you can do it in any other language as well. If you don't know C# and need help understanding my answer, just leave a comment here)
I'm using firebird database and it does not seem to have ROWNUM or ROW_NUMBER() like sql server does so I cannot follow the procedure explained here.
I have a query whose result dataset is bigger than what my system memory can accommodate. I'm trying load the dataset in smaller chunks. I have a series of generic queries which I cannot modify and they could be anything. I know I can do
select first 5000 * from
(-my actual query here-)
to get the first 5000 records. But how can I go about getting the next 5000 records.
Thanks
Since FireBird 2.0 ROWS syntax is supported, ie you would use
select * from tab ROWS m TO n
I suggest you download FB's language reference update where it is documented.
In firebird you use Select First ? Skip ? to specific how many, and what your offset is.
I have a licensing database set up for storing my cutomers' records. However, when I need to find someone, it is hard since it is not in alphabetical order.. And I cannot find an option to sort them in Visual Studio's Server Explorer.
Here is a picture, notice the first name letters I did not cut off, they are not in order: http://img822.imageshack.us/img822/4946/captureeg.png
So how do I fix this problem? Is there some secret button in VS I have to discover?
If using a T-SQL statement, you can rewrite the SQL with an ending of
ORDER BY Name DESC
this will allow it to be alphabetical in descending order and ten it will be easier or when searching add a search clause
WHERE Name = 'Earl Smith'
if you do comment with more specific in how you are getting the table would be helpful as well.
full Query and of course update customer_records to your table name:
SELECT * FROM customer_records ORDER BY Name DESC;
To be exact - this is by SQL standard. No set has an order UNLESS YOU IMPOSE ONE. Which means a ORDER BY part in a SELECT statement. If you dont do that, the return value is technically random and at the discretion of the database server which will come up in them in an order that is as fast as possible to compute.
we have a view in our database which has an ORDER BY in it.
Now, I realize views generally don't order, because different people may use it for different things, and want it differently ordered. This view however is used for a VERY SPECIFIC use-case which demands a certain order. (It is team standings for a soccer league.)
The database is Sql Server 2008 Express, v.10.0.1763.0 on a Windows Server 2003 R2 box.
The view is defined as such:
CREATE VIEW season.CurrentStandingsOrdered
AS
SELECT TOP 100 PERCENT *, season.GetRanking(TEAMID) RANKING
FROM season.CurrentStandings
ORDER BY
GENDER, TEAMYEAR, CODE, POINTS DESC,
FORFEITS, GOALS_AGAINST, GOALS_FOR DESC,
DIFFERENTIAL, RANKING
It returns:
GENDER, TEAMYEAR, CODE, TEAMID, CLUB, NAME,
WINS, LOSSES, TIES, GOALS_FOR, GOALS_AGAINST,
DIFFERENTIAL, POINTS, FORFEITS, RANKING
Now, when I run a SELECT against the view, it orders the results by GENDER, TEAMYEAR, CODE, TEAMID. Notice that it is ordering by TEAMID instead of POINTS as the order by clause specifies.
However, if I copy the SQL statement and run it exactly as is in a new query window, it orders correctly as specified by the ORDER BY clause.
The order of rows returned by a view with an ORDER BY clause is never guaranteed. If you need a specific row order, you must specify where you select from the view.
See this the note at the top of this Book On-Line entry.
SQL Server 2005 ignores TOP 100 PERCENT by design.
Try TOP 2000000000 instead.
Now, I'll try and find a reference... I was at a seminar presented by Itzak Ben-Gan who mentioned it
Found some...
Kimberly L. Tripp
"TOP 100 Percent ORDER BY Considered Harmful"
In this particular case, the optimizer
recognizes that TOP 100 PERCENT
qualifies all rows and does not need
to be computed at all.
Just use :
"Top (99) Percent "
or
"Top (a number 1000s times more than your data rows like 24682468123)"
it works! just try it.
In SQL server 2008, ORDER BY is ignored in views that use TOP 100 PERCENT. In prior versions of SQL server, ORDER BY was only allowed if TOP 100 PERCENT was used, but a perfect order was never guaranteed. However, many assumed a perfect order was guaranteed. I infer that Microsoft does not want to mislead programmers and DBAs into believing there is a guaranteed order using this technique.
An excellent comparative demonstration of this inaccuracy, can be found here...
http://blog.sqlauthority.com/2009/11/24/sql-server-interesting-observation-top-100-percent-and-order-by
Oops, I just noticed that this was already answered. But checking out the comparative demonstration is worth a look anyway.
Microsoft has fixed this. You have patch your sql server
http://support.microsoft.com/kb/926292
I found an alternative solution.
My initial plan was to create a 'sort_order' column that would prevent users from having to perform a complex sort.
I used a windowed function ROW_NUMBER. In the ORDER BY clause, I specified the default sort order that I needed (just as it would have been in the ORDER BY of a SELECT statement).
I get several positive outcomes:
By default, the data is getting returned in the default sort order I originally intended (this is probably due to the windowed function having to sort the data prior to assigning the sort_order value)
Other users can sort the data in alternative ways if they choose to
The sort_order column is there for a very specific sort need, making it easier for users to sort the data should whatever tool they use rearranges the rowset.
Note: In my specific application, users are accessing the view via Excel 2010, and by default the data is presented to the user as I had hoped without further sorting needed.
Hope this helps those with a similar problem.
Cheers,
Ryan
run a profiler trace on your database and see the query that's actually being run when you query your view.
You also might want to consider using a stored procedure to return the data from your view, ordered correctly for your specific use case.