473,385 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Help with an index

I have a SELECT stmt:

SELECT
category.category,
category.description,
ROUND(SUM(CASE
WHEN ((saleitem.price != 0) AND (sale.discount_pct != 0))
THEN saleitem.quantity * saleitem.price * (1 -
(sale.discount_pct / 100))
WHEN ((saleitem.price <> 0) AND (sale.discount <> 0) AND
(sale.gross <> 0))
THEN saleitem.quantity * saleitem.price * (1 - (sale.discount /
sale.gross))
ELSE saleitem.quantity * saleitem.price
END),2) AS curr_year_sales
FROM saleitem
LEFT JOIN sale ON saleitem.sale = sale.number
LEFT JOIN product ON product.product_code = saleitem.item
LEFT JOIN category ON category.category = product.pr_cats_sc_cat
LEFT JOIN subcat ON (subcat.category = product.pr_cats_sc_cat AND
subcat.subcategory = product.pr_cats_sc_num)
WHERE sale.sale_date BETWEEN '2003-10-01' AND '2003-11-01'
AND sale.type <> 'AR'
AND Trim(sale.voided_by) = ''
AND sale.status <> 'R'
GROUP BY category.category WITH ROLLUP

To make this as fast as possible, I think I should have an INDEX on table
sale(sale_date,type,voided_by,status). So far so good? How should the tables
that are JOINied be indexed to make this as fast as possible?

Thanks for any help.

Bill
Jul 19 '05 #1
0 1280

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Gerry | last post by:
Help needed with this: I have had a guestbook-page in Europe and will now have to move it to a US based-server. This makes the time-function showing time 6 hours wrong. The time should be GMT...
4
by: Gerry | last post by:
As I'm not a PHP-prgrammer at all, I just need Help with this: I have had a guestbook-page in Europe and will now have to move it to a US based-server. This makes the time-function showing time...
2
by: Andrew | last post by:
Helo Everyone. Im in need of some help with a C++ method. I am trying to read entries from a MyData.dat file, and enter each of those entries into an array. MyArray was properly declared and...
4
by: David | last post by:
Hello , I'm trying to parse an XML document a get spicific tags such as email in the code below. I'm using xerces 2.4. However I don't manage to get the value for the email. Can anybody help. ...
5
by: jhon02148 | last post by:
hi this hw have four files: 1. for the main program 2. listp.cpp (the source file) 3. listp.h (the header file) 4. exception.h if there is anybody who could help me with this hw i really...
2
by: -D- | last post by:
I'm taking my first stab at using xml, so please bear with my novice questions and understanding of xml. I'm trying to create an xml file that holds all my website navigation. If I understand...
5
by: althafexcel | last post by:
hi everyone Im trying to include an external js in my aspx page under the head tag, it doesn't load or it displays an object expected error whenver the function from the .js is called. Actually...
3
by: Dameon99 | last post by:
Hi.. Im experiencing a weird error I dont know how to fix. I have a scanner object and whenever I use nextInt, anything above 3 causes the program to crash saying and links me to this line of the...
2
by: tonsi | last post by:
I have a page but it wont center the div. Can anyone take a look at it and help. When I try to center in the body using text-align: center; it doesn't work with the main container (called Table_01)....
5
by: ryuchi311 | last post by:
In C++ using arrays. I need to create a C Program that will ask for five integers input from the user, then store these in an array. Then I need to find the lowest and highest integers inside that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.