sql - Correct form long time query executing myodbc syntax -


I am trying to create a SQL query for access to recover data from the Internet that myodbc connection , But the time to complete the query is too long, so I think the problem is with the query:

  SELECT COUNT ([o]. [Order_id] ) Asmany_orders, (SELECT SUM (.. [OP1] [products_quantity]) OT1 from orders_total, as order O1, orders_products OP1 ou [O1] as a In the form [date_purchased]> date =) - 30 and [O1] [orders_id] = [OP1] [... orders_id] and [OT1]. [Orders_id] = [OP1]. [Orders_id] and [OT1 ]. [Class] = "ot_total" and [O1]. [Orders_status] = 1 and [OP1]. [Products_id] = [session]. [Products1] [products1] [product_id] group [op1]. [Products_id]) pediant, [op] . [Products_model], Goal ((7 + 1) * (howmany_orders / 90)) + 1) - (P. Stock_AL- IIF (Pendetta> 0, Pendiantie, 0)), 0) AS Peder, order_tatal AT from PR_ID, According to the order, Inner Join product as order-products at mid-end ([op]. [Products_model], 4) such as p.ref_id where [o]. [Date_purchased]> gt; Date =) - 90 and [O]. [Order_id] = [op]. [Order_id] and [OT]. [Orders_id] = [session]. [Orders_id] and [OT]. [Class] = "ot_total" and [o]. [Orders_status] in (7, 1) and ((p.fuera_de_stock) false =) and ((p.suspendido) false =) and ((p.quitar_de_la_web) = false) group [session] [products_model], p. Ref_id, p.stock_real, [sessions] [products_id] .. At a glance I think that the " Choice " operator may be one of the problems here:  
  INNER Join Productos such as P on Mid ([op]. [Products_model], 4) such as p.ref_id  

but I do not have an option for = operator

Thank you for your help!

Edit: I've reduced that query, but at the same time:

  howmany_orders, as the SELECT COUNT (o.orders_id) (sum (opz. Products_quantity) As the order ounce, order_products as OPZ select from oz.date_purchased & gt; = date () - 30 and oz.orders_id = opz.orders_id and oz.orders_status = 1 and opz.products_id = op. Pendiente, op.products_model, round ((7 + 1) * (howmany_orders / 90)) as the products_id GROUP by opz.products_id + 1) - (p.stock_real-IIf (pendiente & gt 0, pendente, 0 ), 0) AS Peder, as order from PR_ID order, as order-products Inner Inopr on Pemento AS P Oper Prodkts_model = Pikdod where Oadet_prijd & gt; = Date () - 90 and O.orders_id = op.orders_id in an o.orders_status (7.1) and false ((p.suspendido) =) and ((p.quitar_de_la_web) false =) op.products_model, p.ref_id , Group by p.stock_real, op.products_id;  

Yes your problem is that the database may not be included in an index, That is why she has to scan the table. Anyway, can you continue this data so that you do not have to do mid-statement and join it? That is, your products_model table contains an additional column with the middle data stored along with it being included in that column


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -