Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / July 2007

Tip: Looking for answers? Try searching our database.

Access Crah on a query,

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MArc Robillard - 28 Jul 2007 15:26 GMT
Hi all,
I'm new to taht forum so be kind please !

What I need to do is to popullate a list of Order with the total off it.

Some order MAY not have any details.

Sum() is ignoring Null value so I tried this :

SELECT distinct orders.Ord_id, orders.Cst_id,
(select sum(detcmd_qty * detcmd_price) as total from detOrders right join
Orders on Orders.ord_id = detOrders.ord_id) as OrderTotal
FROM orders LEFT JOIN detOrders ON orders.Ord_id = detOrders.Ord_id
WHERE (orders.Cst_id=1)
GROUP BY orders.Ord_id, detOrders.detCmd_id, orders.Cst_id
ORDER BY orders.Ord_id;

the inner select works just fine, and return a total of a specific Order
went I put an ord_id clause.

I need the OrderTotal to show in the list even IF It as no detailOrders.

Any help here would be great !
Marc.
Please responde to NewGroup.
pietlinden@hotmail.com - 28 Jul 2007 20:55 GMT
> Hi all,
> I'm new to taht forum so be kind please !
[quoted text clipped - 21 lines]
> Marc.
> Please responde to NewGroup.

Why not just do a totals query with a left join instead of an inner
join?  And whats the DISTINCT clause in there for?  That woul make
your query TANK!!!
MArc Robillard - 30 Jul 2007 01:37 GMT
That is what I did, (finially got it to work)
For the distinct, I was Trying about any thing ! ..

the actual solution was :

SELECT Orders.Ord_id,
format(Sum(detOrders.detCmd_Qte*detOrders.detCmd_Price),'standard') AS
TotalGross,
format(Sum((detOrders.detCmd_Qte*detOrders.detCmd_Price)*(100-detcmd_discount)/100),'standard')
AS TotalNet,
Orders.Cst_id, Orders.Ord_Date, Orders.Ord_Accepted, Orders.Ord_Printed,
Orders.Ord_Proforma, Orders.Ord_ProformaPrinted, Orders.Devise_id,
Orders.Taxes_id, Orders.Ord_Comments, Orders.Ord_PrintComment,
Orders.Ord_PaymentTerms, Orders.ord_ShippingFeeBase,
Orders.ord_ShippingFeeExtra
FROM detOrders
RIGHT JOIN Orders ON detOrders.Ord_id=Orders.Ord_id
WHERE(Orders.cst_ID = 1)
GROUP BY Orders.Ord_id, Orders.Ord_Date, Orders.Ord_Accepted,
Orders.Ord_Printed, Orders.Ord_Proforma, Orders.Ord_ProformaPrinted,
Orders.Ord_Comments, Orders.ord_ShippingFeeBase,
Orders.ord_ShippingFeeExtra;

>> Hi all,
>> I'm new to taht forum so be kind please !
[quoted text clipped - 25 lines]
> join?  And whats the DISTINCT clause in there for?  That woul make
> your query TANK!!!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.