Search Results

Search found 2750 results on 110 pages for 'recursive subquery factor'.

Page 4/110 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • MySQL multiple dependent subqueries, painfully slow

    - by matt80
    I have a working query that retrieves the data that I need, but unfortunately it is painfully slow (runs over 3 minutes). I have indexes in place, but I think the problem is the multiple dependent subqueries. I've been trying to rewrite the query using joins but I can't seem to get it to work. Any help would be greatly appreciated. The tables: Basically, I have 2 tables. The first (prices) holds the prices of items in a store. Each row is the price of an item that day, and new rows are added every day with an updated price. The second table (watches_US) holds the item information (name, description, etc). CREATE TABLE `prices` ( `prices_id` int(11) NOT NULL auto_increment, `prices_locale` enum('CA','DE','FR','JP','UK','US') NOT NULL default 'US', `prices_watches_ID` char(10) NOT NULL, `prices_date` datetime NOT NULL, `prices_am` varchar(10) default NULL, `prices_new` varchar(10) default NULL, `prices_used` varchar(10) default NULL, PRIMARY KEY (`prices_id`), KEY `prices_am` (`prices_am`), KEY `prices_locale` (`prices_locale`), KEY `prices_watches_ID` (`prices_watches_ID`), KEY `prices_date` (`prices_date`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=61764 ; CREATE TABLE `watches_US` ( `watches_ID` char(10) NOT NULL, `watches_date_added` datetime NOT NULL, `watches_last_update` datetime default NULL, `watches_title` varchar(255) default NULL, `watches_small_image_height` int(11) default NULL, `watches_small_image_width` int(11) default NULL, `watches_description` text, PRIMARY KEY (`watches_ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; The query retrieves the last 10 prices changes over a period of 30 hours, ordered by the size of the price change. So I have subqueries to get the newest price, the oldest price within 30 hours, and then to calculate the price change. Here's the query: SELECT watches_US.*, prices.*, watches_US.watches_ID as current_ID, ( SELECT prices_am FROM prices WHERE prices_watches_ID = current_ID AND prices_locale = 'US' ORDER BY prices_date DESC LIMIT 1 ) as new_price, ( SELECT prices_date FROM prices WHERE prices_watches_ID = current_ID AND prices_locale = 'US' ORDER BY prices_date DESC LIMIT 1 ) as new_price_date, ( SELECT prices_am FROM prices WHERE ( prices_watches_ID = current_ID AND prices_locale = 'US') AND ( prices_date >= DATE_SUB(new_price_date,INTERVAL 30 HOUR) ) ORDER BY prices_date ASC LIMIT 1 ) as old_price, ( SELECT ROUND(((new_price - old_price)/old_price)*100,2) ) as percent_change, ( SELECT (new_price - old_price) ) as absolute_change FROM watches_US LEFT OUTER JOIN prices ON prices.prices_watches_ID = watches_US.watches_ID WHERE ( prices_locale = 'US' ) AND ( prices_am IS NOT NULL ) AND ( prices_am != '' ) HAVING ( old_price IS NOT NULL ) AND ( old_price != 0 ) AND ( old_price != '' ) AND ( absolute_change < 0 ) AND ( prices.prices_date = new_price_date ) ORDER BY absolute_change ASC LIMIT 10 How would I rewrite this to use joins instead, or otherwise optimize this so it doesn't take over 3 minutes to get a result? Any help would be greatly appreciated! Thank you kindly.

    Read the article

  • Good grammar for date data type for recursive descent parser LL(1)

    - by Totophil
    I'm building a custom expression parser and evaluator for production enviroment to provide a limited DSL to the users. The parser itself as the DSL, need to be simple. The parser is going to be built in an exotic language that doesn't support dynamic expression parsing nor has any parser generator tools available. My decision is to go for recursive descent approach with LL(1) grammar, so that even programmers with no previous experience in evaluating expression could quickly learn how the code works. It has to handle mixed expressions made up of several data types: decimals, percentages, strings and dates. And dates in the format of dd/mm/yyyy are easy to confuse with a string of devision ops. Is where a good solution to this problem? My own solution that is aimed at keeping the parser simple involves prefixing dates with a special symbol, let's say apostrophe: <date> ::= <apostr><digit><digit>/<digit><digit>/<digit><digit><digit><digit> <apostr> ::= ' <digit> ::= '0'..'9'

    Read the article

  • Classic ASP Recursive function

    - by user333411
    Hi everyone, I havent done any classic ASP for a couple of years and now trying to get back into it from c# is prooving impossible! I've got a recursive function which very simply is supposed to query a database based on a value passed to the function and once the function has stopped calling itself it returns the recordset....however im getting the old error '80020009' message. I've declared the recordset outside of the function. Cany anyone see the error in my ways? Dim objRsTmp Function buildList(intParentGroupID) Set objRsTmp = Server.CreateObject("Adodb.Recordset") SQLCommand = "SELECT * FROM tblGroups WHERE tblGroups.intParentGroupID = " & intParentGroupID & ";" objRsTmp.Open SQLCommand, strConnection, 3, 3 If Not objRsTmp.Eof Then While Not objRsTmp.Eof Response.Write(objRsTmp("strGroup") & "<br />") buildList(objRsTmp("intID")) objRsTmp.MoveNext Wend End If Set buildList = objRsTmp '#objRsTmp.Close() 'Set objRsTmp = Nothing End Function Set objRs = buildList(0) If Not objRs.Eof Then Response.Write("There are records") While Not objRs.Eof For Each oFld in objRs.Fields Response.Write(oFld.Name & ": " & oFld.Value & ",") next Response.Write("<br />") objRs.MoveNext Wend End If Any assistance would be greatly appreciated. Regards, Al

    Read the article

  • Make function non-recursive

    - by user69514
    I'm not sure how to make this function non-recursive. Any ideas?: void foo(int a, int b){ while( a < len && arr[a][b] != -1){ if(++a == len){ a = 0; b++; } } if( a == len){ size++; return; } if( a < (len-1)){ arr[a][b] = 1; arr[a][(b+1)] = 1; foo(a, b); arr[a][b] = -1; arr[a][(b+1)] = -1; } if( a < (len-1) && arr[(a+1)][b] == -1){ arr[a][b] = 0; arr[(a+1)][b] = 0; foo(a,b); arr[a][b] = -1; arr[(a+1)][b] = -1; } }

    Read the article

  • Breadcrumbs - The New Ranking Factor in SEO

    Breadcrumbs were traditionally used as means of navigation factor for the visitors. Since then, the use of breadcrumbs has gone under a change and breadcrumbs have come to hold an important position in boosting the SEO process of a website.

    Read the article

  • Can a recursive function have iterations/loops?

    - by Omega
    I've been studying about recursive functions, and apparently, they're functions that call themselves, and don't use iterations/loops (otherwise it wouldn't be a recursive function). However, while surfing the web for examples (the 8-queens-recursive problem), I found this function: private boolean placeQueen(int rows, int queens, int n) { boolean result = false; if (row < n) { while ((queens[row] < n - 1) && !result) { queens[row]++; if (verify(row,queens,n)) { ok = placeQueen(row + 1,queens,n); } } if (!result) { queens[row] = -1; } }else{ result = true; } return result; } There is a while loop involved. ... so I'm a bit lost now. Can I use loops or not?

    Read the article

  • R: How to plot data grouped by a factor, but not as a boxplot

    - by amarillion
    In R, given a vector casp6 <- c(0.9478638, 0.7477657, 0.9742675, 0.9008372, 0.4873001, 0.5097587, 0.6476510, 0.4552577, 0.5578296, 0.5728478, 0.1927945, 0.2624068, 0.2732615) and a factor: trans.factor <- factor (rep (c("t0", "t12", "t24", "t72"), c(4,3,3,3))) I want to create a plot where the data points are grouped as defined by the factor. So the categories should be on the x-axis, values in the same category should have the same x coordinate. Simply doing plot(trans.factor, casp6) does almost what I want, it produces a boxplot, but I want to see the individual data points.

    Read the article

  • R: How to plot a vector, grouped by a factor

    - by amarillion
    In R, given a vector casp6 <- c(0.9478638, 0.7477657, 0.9742675, 0.9008372, 0.4873001, 0.5097587, 0.6476510, 0.4552577, 0.5578296, 0.5728478, 0.1927945, 0.2624068, 0.2732615) and a factor: trans.factor <- factor (rep (c("t0", "t12", "t24", "t72"), c(4,3,3,3))) I want to create a plot where the data points are grouped as defined by the factor. So the categories should be on the x-axis, values in the same category should have the same x coordinate. Simply doing plot(trans.factor, casp6) does almost what I want, it produces a boxplot, but I want to see the individual data points.

    Read the article

  • Motion Sensing Fog Machine Increases Savings and Spook Factor

    - by Jason Fitzpatrick
    This DIY add-on switches a standard fog machine from always-on to motion-activated–increase your savings and spook factor at the same time. Courtesy of tinker Greg, this modification involves a new relay and motion sensor mounted onto the existing switch of a store-bought fog machine. When the motion-sensor detects motion the fog machine releases a burst of fog for 5 seconds and then disarms itself for 10 seconds–long enough for the startled victim to move on and for the machine to recharge for the next passerby. Check out the video above to see it in action and then hit up the link below to see the project’s build guide. Motion Sensing Fog Machine Trigger [via Hack A Day] How Hackers Can Disguise Malicious Programs With Fake File Extensions Can Dust Actually Damage My Computer? What To Do If You Get a Virus on Your Computer

    Read the article

  • Is Java easy decompilation a factor worth considering

    - by Sandra G
    We are considering the programming language for a desktop application with extended GUI use (tables, windows) and heavy database use. We considered Java for use however the fact that it can be decompiled back very easily into source code is holding us back. There are of course many obfuscators available however they are just that: obfuscators. The only obfuscation worth doing we got was stripping function and variables names into meaningless letters and numbers so that at least stealing code and renaming it back into something meaningful is too much work and we are 100% sure it is not reversible back in any automated way. However as it concerns to protecting internals (like password hashes or sensible variables content) we found obfuscators really lacking. Is there any way to make Java applications as hard to decode as .exe counterparts? And is it a factor to consider when deciding whether to develop in Java a desktop application?

    Read the article

  • In SQL, can we always write an inner join statement as a main query and subquery if we only want to

    - by Jian Lin
    In SQL, can we always write an inner join statement as a main query and subquery or vice versa if we only want to find the intersection? For example, select * from gifts g where g.giftID in (select giftID from sentGifts); can do a join and show the gifts sent in the sentGifts table, but it won't be able to show the sentTime because that is inside the subquery. But if all we care is to find the intersection, without caring what is being displayed, then we can always convert one to the other?

    Read the article

  • ruby recursive regex

    - by Reed Debaets
    So why is this not working? I'm creating a regex that will match a formula (which is then part of a larger standard description). But I'm stuck here, as it doesn't appear to want to match embedded formulas within a formula. stat = /(Stat3|Stat2|Stat1)/ number_sym = /[0-9]*/ formula_sym = /((target's )?#{stat}|#{number_sym}|N#{number_sym})\%?/ math_sym = /(\+|\-|\*|\/|\%)/ formula = /^\((#{formula}|#{formula_sym}) (#{math_sym} (#{formula}|#{formula_sym}))?\)$/ p "(target's Stat2 * N1%)".match(formula).to_s #matches p "((target's Stat2 * N1%) + 3)".match(formula).to_s #no match p "(Stat1 + ((target's Stat2 * N1%) + 3))".match(formula).to_s #no match

    Read the article

  • Recursive follow files in bash

    - by user328955
    I have files which contain file names pointing to other files. These files contain further file names pointing further files and so on. I need a bash script which follows each files recursively and logs into file every touched file during the run. file1: file2 file3 file2: file4 file3: file5 file4 and file5 are empty. Result: file1 file2 file4 file3 file5

    Read the article

  • php run function on all images from one dir in recursive mode (noob)

    - by Steve
    hey guyz i have a function $result = create_watermark( 'input_file_name' ,'output_file_name'); i have dir called /images n have 500 images in it and all images are link images_(some_unknown_numbers).png (all png) now i want run them thru function in loop and want out put like /markedimage/images_1.png images_2.png images_3.png i need help how can i run them in loop and how out put name can change want run script on Ubuntu so we can use shell too if any body want check function it is here http://paste2.org/p/789149 plz provide me code because i m newbie thanks in advance

    Read the article

  • Regex for recursive "wiki-style" lists

    - by Syd Miller
    I'm trying to create a Regular Expression to match "wiki style" lists as in (using preg_replace_callback() ): * List Item 1 * List Item 2 *# List Item 2.1 *# List Item 2.2 * List Item 3 Asterisks denote Unordered Lists while Number-Signs denote Ordered Lists. I'm trying to get this so it can match infinite depth and so that * and # can be mixed. I tried the following expression (and variations of it): /\s([*#]{1,}) ([\S ]+)\s/si But it doesn't seem to want to work. What am I doing wrong? Or is there a better way of accomplishing this?

    Read the article

  • Recursive CTE with alternating tables

    - by SOfanatic
    I've created a SQL fiddle here. Basically, I have 3 tables BaseTable, Files, and a LinkingTable. The Files table has 3 columns: PK, BaseTableId, RecursiveId (ChildId). What I want to do is find all the children given a BaseTableId (i.e., ParentId). The tricky part is that the way the children are found works like this: Take ParentId 1 and use that to look up a FileId in the Files table, then use that FileId to look for a ChildId in the LinkingTable, if that record exists then use the RecursiveId in the LinkingTable to look for the next FileId in the Files table and so on. This is my CTE so far: with CTE as ( select lt.FileId, lt.RecursiveId, 0 as [level], bt.BaseTableId from BaseTable bt join Files f on bt.BaseTableId = f.BaseTableId join LinkingTable lt on f.FileId = lt.FileId where bt.BaseTableId = @Id UNION ALL select rlt.FileId, rlt.RecursiveId, [level] + 1 as [level], CTE.BaseTableId from CTE --??? and this is where I get lost ... ) A correct output for BaseTableId = 1, should be: FileId|RecursiveId|level|BaseTableId 1 1 0 1 3 2 1 1 4 3 2 1

    Read the article

  • Recursive SQL, have the last three values increased?

    - by Mike
    Hi, I have a table that looks like this: ---------------------- | DateTime | Value | ---------------------- | 2010-01-01 | 26 | | 2010-02-01 | 24 | | 2010-03-01 | 23 | | 2010-04-01 | 28 | | 2010-05-01 | 30 | I need to find if the last three consecutive months have increased in value. How can I get SQL to check whether the value for each has increased? If anyone can give me any pointers for solving this problem it would be greatly appreciated! Thanks

    Read the article

  • jQuery recursive function to upload many files while giving the user some feedback

    - by checcco
    Hi guys, I'm trying to write a jQuery function to let users upload many files at once. Here's the function I thought to give the user some feedback about the upload process progress. function uploadFiles(numbersOfFiles, start) { $("#info").html(start + " files uploaded"); $.post('upload.php', { start: start }, function (data) { start += 5; if (start < numbersOfFiles) { $("#info").html(start + " files uploaded"); uploadFiles(numbersOfFiles, start); } else { $("#info").html("All files have been uploaded"); } }); } The function calls a php script to upload 5 files, then if there are more files to upload it calls the script again. The whole process works. I've tried it with 100 files. The only thing that doesn't work is the #info div updating. The div get updated the first time and then again only to show "All files have been uploaded". So there's no feedback for the user about the uploading process. I can't understand why... Any help?

    Read the article

  • C# recursive programming with lists

    - by David Torrey
    I am working on a program where each item can hold an array of items (i'm making a menu, which has a tree-like structure) currently i have the items as a list, instead of an array, but I don't feel like I'm using it to its full potential to simplify code. I chose a list over a standard array because the interface (.add, .remove, etc...) makes a lot of sense. I have code to search through the structure and return the path of the name (i.e. Item.subitem.subsubitem.subsubsubitem). Below is my code: public class Item { //public Item[] subitem; <-- Array of Items public List<Item> subitem; // <-- List of Items public Color itemColor = Color.FromArgb(50,50,200); public Rectangle itemSize = new Rectangle(0,0,64,64); public Bitmap itemBitmap = null; public string itemName; public string LocateItem(string searchName) { string tItemName = null; //if the item name matches the search parameter, send it up) if (itemName == searchName) { return itemName; } if (subitem != null) { //spiral down a level foreach (Item tSearchItem in subitem) { tItemName = tSearchItem.LocateItem(searchName); if (tItemName != null) break; //exit for if item was found } } //do name logic (use index numbers) //if LocateItem of the subitems returned nothing and the current item is not a match, return null (not found) if (tItemName == null && itemName != searchName) { return null; } //if it's not the item being searched for and the search item was found, change the string and return it up if (tItemName != null && itemName != searchName) { tItemName.Insert(0, itemName + "."); //insert the parent name on the left --> TopItem.SubItem.SubSubItem.SubSubSubItem return tItemName; } //default not found return null; } } My question is if there is an easier way to do this with lists? I've been going back and forth in my head as to whether I should use lists or just an array. The only reason I have a list is so that I don't have to make code to resize the array each time I add or remove an item.

    Read the article

  • Smooth Camera Zoom Factor Change

    - by Siddharth
    I have game play scene in which user can zoom in and out. For which I used smooth camera in the following manner. public static final int CAMERA_WIDTH = 1024; public static final int CAMERA_HEIGHT = 600; public static final float MAXIMUM_VELOCITY_X = 400f; public static final float MAXIMUM_VELOCITY_Y = 400f; public static final float ZOOM_FACTOR_CHANGE = 1f; mSmoothCamera = new SmoothCamera(0, 0, Constants.CAMERA_WIDTH, Constants.CAMERA_HEIGHT, Constants.MAXIMUM_VELOCITY_X, Constants.MAXIMUM_VELOCITY_Y, Constants.ZOOM_FACTOR_CHANGE); mSmoothCamera.setBounds(0f, 0f, Constants.CAMERA_WIDTH, Constants.CAMERA_HEIGHT); But above thing create problem for me. When user perform zoom in and leave game play scene then other scene behaviour not look good. I already set zoom factor to 1 for this purpose. But now it show camera translation in other scene. Because scene switching time it so much small that player can easily saw translation of camera that I don't want to show. After camera reposition, everything works perfect but how to set camera its proper position. For example my loading text move from bottom to top or vice versa based on camera movement. Any more detail you want then I can able to give you.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >