max

select sum where sum

Hi there, I want to select some entries based on a max+sum condition. mytable ---------- id | col1 | col2 I want to select all entries that have the sum of col1 & col2 greater than or equal to the max of sum minus X. (don't ask me why :) ) So far I managed to get the sum OK (hereafter aliased as "total") with: SELECT id,SUM(col1 +...

Treat Null as Max

Hey, So if I had a table in my database with the values 1 2 3 4 NULL And I executed the query SELECT MAX(col1) FROM <table> I'd get 4. Is there any way to change this so Null would be treated as the maximum as oppose to the minimum? Thanks! ...

Problem reading files greater than 1GB with XMLReader

Is there a maximum file size the XMLReader can handle? I'm trying to process an XML feed about 3GB large. There are certainly no PHP errors as the script runs fine and successfully loads to the database after it's been run. The script also runs fine with smaller test feeds - 1GB and below. However, when processing larger feeds the scr...

Get MAX() on column in two tables

I have two tables which both have the column DateTime. How can I get the MAX() DateTime? The shorter/simpler the better, because this is just part of a larger query. ...

MIN and MAX in C

Where are MIN and MAX defined in C, if at all? What is the best way to implement these, as generically and type safe as possible (compiler extensions/builtins for mainstream compilers preferred). ...

C extension: <? and >? operators

I observed that there was at some point a <? and >? operator in GCC. How can I use these under GCC 4.5? Have they been removed, and if so, when? Offset block_count = (cpfs->geo.block_size - block_offset) <? count; cpfs.c:473: error: expected expression before ‘?’ token ...

How to return maxvalue or nullvalue in SQL?

Hello, I'm running requests on an Oracle database. One of my tables contains time slots for Elements and there can be several time slots for the same Element so that the following example is correct : ID ELEMENT_ID BEGIN_DATE END_DATE -------------------------------------------- 1 1 01/01/2007 01/06/2007 2 ...

Hierarchical MAX

Is there a way to get a row that has the MAX() when two fields are considered, giving one of them precedence. For example ID Column_A Column_B ---------------------------- 1 1 3 2 3 2 3 2 2 4 3 1 Would return ID Column_A Column_B --------...

Python midi out to FruityLoops Studio

hi everybody, im working on a project and i want to create a virtual midi input with python to flstudio (fruityloops) i have googled a bit but all the modules i could find was about creating midi files which is not my issue. so what module should i use for midi i/o with python? ...

SQL - fetch latest row with data in specific column or just latest row if no data in that column

I have a table that records a history of address updates, called transaction. The schema is something like row_id (int, PK), user_id (int), address1 (varchar), transdate (timestamp). I want to query the table and have a single row returned for a user showing what is the latest row (i.e. greatest timestamp), but if there is data in the ...

MySQL - select multiple maximum values

I have a table called order which contains columns id, user_id, price. I would like to select each user's most expensive order - the order for which that user paid the highest price. I want to select order.user_id and order.price in the same query. ...

Get maximum value with Zend_Db_Table

Hi, Ive got a Zend_Db_Table Now I want to get the maximum available value of a field. Is there a way to get the MAX(number) value or do I need to use basic SQL? Thanks! ...

why both the sql query on rownum are giving different result

>SELECT instmax FROM (SELECT instmax, rownum r FROM ( SELECT * FROM pswlinstmax ORDER BY instmax DESC NULLS LAST ) ) WHERE r = 2; INSTMAX ------- 1049 >SELECT instmax FROM (SELECT instmax, rownum FROM (SELECT * FROM pswlinstmax ORDER BY instmax DESC ) ) WHERE...

MySQL - select multiple maximum values

I have a table called order which contains columns id, user_id, price and item_id. Item prices aren't fixed and I would like to select each item's most expensive order. I want to select user_id, item_id and price in the same query. I tried the following query but it doesn't return the correct result set. SELECT user_id, item_id, MAX(pri...

Finding The Max of sum of elements in matrix in distinct rows and columns

Hi, I have a nxm matrix and I need to find the maximum of sum of its values in distinct rows and columns. For example considering the following Matrix: m1 m2 m3 n1 1 2 3 n2 4 5 6 n3 7 8 9 n4 10 11 12 The max will be 12+8+4 = 24 Note that finding the max and eliminating all values belonging to that column or ...

How to use Max function on another column from a select

There is query which is asking for favourite products which is bought by each coustomer. i have to select and in the first select i have selected the count of products that each customer bought. in the other select i want to select the maximum of that boughts for each customer.but when i want to select max(previous select column) it gets...

Deleting a row based on the max value.

How can I structure a mySQL query to delete a row based on the max value. I tried WHERE jobPositonId = max(jobPostionId) but got an error? ...

Deleting with Max

This is based on my previous question. I have the following table Table1 JobPositionId | JobPositionName 1 | Sound 2 | Lights 3 | Sound 4 | Ground How can I delete row three (Name = sound, and max position) ...

SQL Query value divided by the max(value)

Hi, I'm ashamed of myself 'cause i can't do this query properly... I have a table like this nom | code_geo | valeur | indice -------+----------+--------+-------------------- AISNE | 02 | 81573 | 0.05 SOMME | 80 | 79520 | 0.03 OISE | 60 | 70004 | 0.09 what i need to do is divide each "indice" by the m...

what is the max size of TextProperty on google app engine .

class JsTree_JsonData(db.Model): JsonData=db.TextProperty() i can;t find what is the TextProperty did you know ? thanks ...