Link to home
Start Free TrialLog in
Avatar of cyberfyb
cyberfyb

asked on

Complex SQL Query

Hi, I have a very complex (for me it is) query to built. the reason why I neeed this complex query is because I need to use the new datagrid element from ASP.NET but that is another story. so I need the result of this query to fit exactly what I try to do.

Now, I will continue to try this until it will work and/or until somebody (like you) will getr me back with the explication of how to do it right.

I have a table for the product:

Product (table)
id (integer, PK)
name (varchar)
description (varchar)

I have an order table:
id (integer, PK)
orderdate (date)
clientid (integer)
etc...

I have an orderdetails table:
id (integer, PK)
orderid (integer)
productid (integer)
quantity (integer)
price (float)

I have a client table:
id (integer, PK)
firstname (varchar)
lastname (varchar)
etc...

Here is what I need:

For each Order.ClientID, I need all :
- Product.name
- OrderDetails.Quantity
- OrderDetails.Price
- Subtotal (OrderDetails.Quantity * OrderDetails.Price).

---

I know I have to play with join but to be honiest with you, since 1996 I develop dynamic web site that interact with database but I never be complex like this because I always plys with For...next, Do while... etc statement that let me create complex table instead of complex query (and repass into the database like 4-6 times instead of only one like what I try to do now). But for what I try to do 9datagrid), I need only one result from the database.

Thank you in advance if you can help me or if you can't, just let me know so I will try some other resource. If you need any more details or informations about this request, just let me know.
ASKER CERTIFIED SOLUTION
Avatar of andrewst
andrewst

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Lowfatspread
Lowfatspread
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Split: andrewst {http:#8234235} & Lowfatspread {http:#8238434}

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

walterecook
EE Cleanup Volunteer