Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    MYSQL




Returning Values That Are In One Table, But Not In Another


I'm looking for a query to return values which occur in one table, but not in the other.

Say we have two tables (table_1, table_2) each with a column titled "appointments".

I want a list of results for appointments which are in table_1, but not in table_2

I have tried the following, but all I get is a huge list of duplicate appointments which occur in both tables:

SELECT table_1.appointments
FROM table_1, table_2
WHERE table_1.appointments<>table_2.appointments;

I've also tried 'NOT IN' for this but the result was just the same.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Returning All Unique Values From A Table Field
I wrote a select that works fine but I am looking at it and thinking that the query might require mysql to scan EVERY row before giving me my answer.

Lets pretend I have a table with fruits and want to return all the available colors of those fruits that I currently have in the database.

Is this an efficient or horribly inefficient statement?

"select color from fruits group by color"

It seems to return what I want:

fruits:
------
blue
green
yellow
...

I am just wondering if it goes through EVERY row and groups them?
If I have the table indexed by color am I allright?

Returning All Values
I'm sure this is a straight forward and obvious one:

I have this:

SELECT *
FROM tbl_contacts
WHERE con_Customer = "#URL.con_Customer#"
Which obviously when you pass a value over the url returns the relevant records.

How can I pass a value to the url which passes ALL the records back.
Is it something like ?con_customer='%'?

Subquery In IN() Not Returning All Possible Values
I'm sure there is some silly little mistake in here somewhere, but I can't find it. This is my first stab at subqueries, so I'm not at all surprised that I'm not getting the correct results.....

Returning Row Id For Added Values
This is probably a simple problem, but I don't know what term describes it so I've had trouble searching for a solution.

I have a table with an automatically incrementing primary key that I am adding data to. I would like to be able to return the row numbr (primary key) of the row to which the new data is being inserted.

Returning Unique Values
I currently have a table called “pages” containing the following columns:
pageid, domainid, location, lastread
I've put together a query that returns 10 rows with the lowest “lastread” values, for which this works fine:
SELECT * FROM pages ORDER BY lastread ACS LIMIT 0,10;

I now the have the added complication that I want to make sure each value in “domainid” is unique. That is to say, not repeated within the 10 results returned. I though I might be able to do something using “GROUP BY domainid” but that cannot just work on the one column as far as I can see.

Stored Proc Returning Values
I know its a newbie problem that much I do know but not sure what I am doing wrong

I have three output parameters defined
outUserID
outUserName
outPass

The select statment that I want to execute is:

Select UserID, UserName, Pass from tbl_security

Looking at the documentation the Stored Proc SQL Statement

Should be the following:

SELECT UserID INTO outUserID, UserName INTO outUserID, Pass INTO outPASS FROM tbl_security;

but this doesn't work and says the UserName varialbe is not declared.

DISTINCT Returning Different Values Than GROUP BY
Here's the results of the two queries obfuscated:
mysql> TRUNCATE normalized;
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> INSERT INTO normalized (a, b, c, d, e)
-> SELECT DISTINCT a, b, c, d, e
-> FROM flattened;
Query OK, 23003 rows affected (46.95 sec)
Records: 23003 Duplicates: 0 Warnings: 0

mysql>
mysql>
mysql> TRUNCATE normalized;
Query OK, 0 rows affected (0.03 sec)

mysql>
mysql> INSERT INTO normalized (a, b, c, d, e)
-> SELECT a, b, c, d, e
-> FROM flattened
-> GROUP BY a, b, c, d, e;
Query OK, 47629 rows affected (45.14 sec)
Records: 47629 Duplicates: 0 Warnings: 0

Note that the number of records in the DISTINCT was 23,003 while the number of records using the GROUP BY (which returned the correct number, btw) was 47,629.

For reference, the column types are as follows:

a = varchar
b = varchar
c = varchar
d = int
e = int

Why would GROUP BY return more (and correct) results vs. DISTINCT? Is there a number of fields that are limited?

One of the other things that doesn't make any sense at all is that the data from the distinct is actually wrong at times. For example, the value of the last column would be incorrect entirely with the data from the flat table.

LEFT JOIN Returning NULL Values
I am trying to perform a LEFT JOIN on a table which may or may not have
matching rows.

If there are no matching rows, it returns NULL's for all the missing fields.

Is there anyway of returning the default values for that table instead of
NULL's, in a portable way?

My query currently looks like this:

SELECT i_product.name, i_product.price, `i_tax-rate`.rate
FROM i_product
LEFT JOIN `i_tax-rate` ON (`i_tax-rate`.`tax-rate-id` =
i_product.`tax-band-id`)
WHERE i_product.id = 123';

Returning 1 Tables Results From Two Table Query
I am executing a query which finds a criteria from certain records in table A and returns all values from table B if the criteria in table A is true. I want to return only the data from table B but can't find an easy way to do that? E.g the MySQL 'From' expression contains both tables.

Multi-table Queries Returning 0 Rows
I'm working on a Windows client program in C++, using Qt and OleDbPro (for
database access). Everything was working great until I had to use a query
for the first time in the code that pulled data from two tables. The query
executes, but returns 0 rows. I verified that the query should return rows
by running the query both through another client using an ODBC DSN, and
using phpMyAdmin; both times, I got the result I expected.
I'm using the following connection string:
Driver={MySQL ODBC 3.51
Driver};server=2ksvr;database=mydb;uid=user;pwd=pa sswd;option=16386
I tried with and without using the JOIN format, someone suggested some ODBC
drivers don't work well with JOINs, but didn't make any difference
So, the question I have is, is there something special I have to do for a
DSN-less connection using an ODBC provider?

Returning Rows In Left Table Based On Mutliple Criteria In Right
This is starting to get to me. I'm sure there's a simple way of handling what i'm trying to do, but someone might be able to help out quicker than spending another hour searching and testing for this. Here's the problem:
Simplified tables:
ARCADES
=======
ID,
name
GAMES
======
ID,
name
ARCADES_GAMES
=============
ID,
arcade_iD
Games_ID
Straightforward enough so far right? I'm trying to get all arcades that have ALL games in a passed in set of game_id's. So for instance I might want all arcades that have the games 11 and 14, but it must have both those.
I can do soemthing like...

SELECT a.name
FROM arcades a
WHERE EXISTS(SELECT 1 FROM arcades_games
WHERE arcade_id=a.id AND game_id IN (11,14))
But that'll return all rows that match ANY of (11,14) rather than ALL of 11,14.

It all comes down to the simple thing of getting rows in a table where all criteria from a list is met, but any advice on how i would do something like this?

Multi-table Queries Returning 0 Rows With DSN-less Connection ViaOLEDB
I'm working on a Windows client program in C++, using Qt and OleDbPro (for
database access). Everything was working great until I had to use a query
for the first time in the code that pulled data from two tables. The query
executes, but returns 0 rows. I verified that the query should return rows
by running the query both through another client using an ODBC DSN, and
using phpMyAdmin; both times, I got the result I expected.

I'm using the following connection string:
Driver={MySQL ODBC 3.51
Driver};server=2ksvr;database=mydb;uid=user;pwd=pa sswd;option=16386

I tried with and without using the JOIN format, someone suggested some ODBC
drivers don't work well with JOINs, but didn't make any difference

So, the question I have is, is there something special I have to do for a
DSN-less connection using an ODBC provider?

Multi-table Queries Returning 0 Rows With DSN-less Connection ViaOLEDB
I'm working on a Windows client program in C++, using Qt and OleDbPro (for
database access). Everything was working great until I had to use a query
for the first time in the code that pulled data from two tables. The query
executes, but returns 0 rows. I verified that the query should return rows
by running the query both through another client using an ODBC DSN, and
using phpMyAdmin; both times, I got the result I expected.

I'm using the following connection string:
Driver={MySQL ODBC 3.51
Driver};server=2ksvr;database=mydb;uid=user;pwd=pa sswd;option=16386

I tried with and without using the JOIN format, someone suggested some ODBC
drivers don't work well with JOINs, but didn't make any difference

So, the question I have is, is there something special I have to do for a
DSN-less connection using an ODBC provider?

INSERTing Into A Table, With Values From Another Table
I'm programming a shopping cart application, where the products are categorized into different lines. I have a table that defines the different product lines, and now want to populate the product table.

However, the text file with the products in it, which I will use to populate the products table, uses the line NAME for each product, when I wish to use the line ID instead. To get the line ID, I would need to get the value from the line table.

My question is: is it possible to populate the products table with data from the products text file, as well as a column from the lines table?

That is, the INSERT (or LOAD DATA) statement will insert column values from the text file, but the line id from the lines table instead of the line name found in the file (WHERE line name = line name in the lines table).

I'm still not sure whether to use an INSERT, and write PHP code to go through the text file, or to use LOAD DATA for this task, because I don't know which statement would support what I'm looking for.



Insert Table Values From Another Table
I have two tables: Users and metadata

Users:
id
userid
username

Metadata:
id
userid
value

I would like to extract a list of the userid's from the users table and enter them into the metadata table, with an additional value.

Example:
I want to take all of the userid's from the User table and insert them into the Metadata table, and make the value="one" for each entry into the Metadata table.

Update One Table Value With Values From Another Table
I am trying to update one table value with values from another table, and I cannot get it to work. What am I doing wrong?

This is my SQL-command:
UPDATE tabel1 SET tabel1.name=tabel2.name WHERE tabel1.ID=tabel2.ID

Inserting Values From 1 Table Into Another Table
I have 2 tables: A and B
Table A contains fields u, x and y
Table B contains fields u and z

Table A has all possible variations of u.
Table B has some of the varaiations of u in it.

My problem is that I'm trying to insert the z-values from Table B into Table A's y field and link them up based on the u-values.

I'm running into problems like truncating at row 0.

I've tried the following queries:

update TableA set y =(select TableB.z from TableB where TableA.u=TableB.u)

update TableA,TableB set TableA.y =(select TableB.z from TableB where TableA.u=TableB.u)

Add Values To Table
I have a table tblMailingList. It has 3 columns; Name, EmailAdd, AutoID.

I am using
mysql> INSERT INTO pet
-> VALUES ('name1','u@me.com');

but I am unsure as to what to do for the AutoID field. If I use the example given, the error message says that the number of fields is different.
How do I get this info into my table?

INSERT Values From One Table To Another
In table A i have a.id and name and in table B, i have b.id, a.id(FK) and owns.

Table A
--------------
a.id | name |
--------------
12 | James |
13 | Paul |
14 | Tom |
15 | Andy |


Table B
--------------

b.id | a.id | owns |
--------------------
1 | 12 | Car |
2 | 12 | Bike |
3 | 13 | PC |

Now what i want is to add two new names to table A which will be Tom and Andy and have the same data in table B for Tom and Andy with just different b.id (PK).

How can i insert this new data in table B using insert?

Update A Table With Values In Another
I have the following table

tableA
column_a
column_x
column_y
column_z

tableB
column_x
column_y
column_z

How do I update the rows of tableA that match rows of tableB (all rows
of tableB are unique)

What I want to acheive is a check against tableA.column_x with
tableB.column_x, if they match, then update the row in tableA.column_y
with the value of tableB.column_y and tableA.column_z with
tableB.column_z

Edit Values In Table Through GUI
I wonder which GUI tool I can use if I want to edit some values in a table? I can't find it in Query Browser. Do I really need to execute SQL to make a simple change to a field?

Update Table Values
I have a csv.txt file with contacts and their information in it. Then I also have a table in mysql with the same contacts and their various information. I need to merge these to so that if a field value in the database is NULL the value that is in the csv.txt file is inserted into the database field.

I have been looking at the mySQL site on how to do this but have not been able to produce a working solution. Below is a more detailed example of what I am looking for. Code:

Get The 3 Highest Values From A Table
My problem is to get the 3 highest values from a table

Editing Values In A Table
I just moved from SQL Server to MySQL and in the Enterprise Manager in SQL Server I could query the entire table and then modify the values with the table without writing an UPDATE statement.
I cannot do that in one of my tables because the EDIT at the bottom is greyed out. There are other tables where I can make a modification to any value I want within the table.

Inserting Values Into A Mapping Table
I am using a mapping table with two primary keys (ID1, ID2). When I try to insert data into this table I get the following error:
Quote:

Violation of PRIMARY KEY constraint 'PK_myTable'. Cannot insert duplicate key in object 'dbo.myTable'. The statement has been terminated.

I am able however to insert values if I do it directly into my table.
Here is an excerpt of my

comm = New SqlCommand( _
"INSERT INTO myTable (ID1, ID2) " & _
"VALUES (@ID1, @ID2)", conn)
' Add command parameters
comm.Parameters.Add("@ID1", System.Data.SqlDbType.Int)
comm.Parameters("@ID1").Value = ID1List.SelectedItem.Value
comm.Parameters.Add("@ID2", System.Data.SqlDbType.Int)
comm.Parameters("@ID2").Value = ID2List.SelectedItem.Value

Generating A Table With Missing Values In SQL
I have the following table:

+------+------+------+-----------+
|ID |GROUP |CODE |ANSWER |
+------+------+------+-----------+
|1 |1 |001 |01-01-2003 |
|2 |1 |002 |Yes |
|3 |1 |003 |NA |
|4 |1 |004 |297797 |
|5 |1 |005 |0 |
|6 |2 |002 |Yes |
|7 |2 |004 |297852 |
|8 |2 |005 |1 |
+------+------+------+-----------+

This means that code 001 and 003 of group 2 are missing. Result of the
query should be:

+-------+-----------+-----------+-----------+-----------+--------+
|GROUP |ANSWER1 |ANSWER2 |ANSWER3 |ANSWER4 |ANSWER5 |
+-------+-----------+-----------+-----------+-----------+--------+
|1 |01-01-2003 |Yes |NA |297797 |0 |
|2 |NULL |Yes |NULL |297852 |1 |
+-------+-----------+-----------+-----------+-----------+--------+

The missing values should be replaced by a NULL value in my resultset.
Is this possible? I don't have any clue how my query should look like,
can anyone help me and show me a solution?

Eliminating Double Values From A Table
I need to consolidate data from many adress databases, which iallready sucessfully put into one table1. As Newbie i am reviing the Manuals and tutorials, but in 2 days i learned a lot about the powerfull command, but not how to solve the following question:

Is there a straight forward method to copy data from one table1 into the other table2, but not those rowse, which have same value in Fieldx.

All my Update and INSERT SELECT experiments somehow created more then less data in the target table.

Update Query Where Values Will Come From Other Table
I'm creating an update query which the value will come from another table.

I have here my current query which unfortunately makes the system hangs. Probably because of the query itself is not properly coded.

update boxes b inner join messages m
on b.ctnnumber = m.ctnno
set b.consigneerecv = m.CName,
b.consigneerecvdate = m.DateRcv,
b.phrecventered = "Y",
b.PhilStatus = "delivered",
b.prevreleasestatus = b.releasestatus,
b.releasestatus = "delivered",
b.PhilStatusDate = m.smsrecvdate,
b.phdelprice = "0.00",
b.phdelamt = "0.00",
b.recvrelation = m.Relation,
b.APRecventered = m.smsRecvDate
where b.consigneerecv = ''
or b.consigneerecv = 'NA'
or b.consigneerecv is null;

I'm thinking revising it so that it will not cause the system to hang but I don't know how. Guys please help me with this one. I also have this another idea which probably will not work. My idea was something like this:

Update table1 set table1.column1 = (select table2.column1 where table2.column1 = table1.column1),
table1.column2 = (select table2.column2 where table2.column1 = table1.column1), .....

Insert Values Only If They Do Not Already Exist In Table
I want to insert some values from one table (A) into another table (b). However there are some values in table A which exist two times in table A. I only want to insert values one time. So If a certain field value also exist in some other row (same fieldname) then I don't want to insert it twice. It doesn't matter which of the two rows will be inserted.

Can this be done with MySQL? Maybe with some Control Flow Functions?

Updating A Table To Increment Values
Question, if I want to update all values in a certain column to increment by one, what statement could I use? In quasi-MySQL, this is my pseudocode:

UPDATE table SET fields=[previous_val+1] where [previous_val]>[my_val]

Or do I HAVE to run a SELECT query, increment the value, and THEN Update it?

I was just thinking there'd be an easier way.

Accepting Values As NULL When Not In Another Table
Is it possible to perform a SELECT query on multiple tables and simply accept one of the values as NULL if not in another table rather than the whole query failing?

For instance, if "rec_id" exists in "table_1" for certain but it is uncertain if it exists in "table_2", is it possible to return the query with a variable assignment stating whether "rec_id" was or wasn't found in "table_2"?

I am hoping I can do this without a LEFT OUTER JOIN as the query is fairly complex and involves five different tables. Whenever results are fetched I simply need to know if rec_id is or isn't in table_2 if it is found in table_1.

As there are frequently over 10,000 result rows returned it wouldn't be sound to put this into a seperate loop that queries with each rec_id to see if it is in table_2.

I have tried "SELECT table_1.rec_id, table_2.rec_id FROM table_1, table_2 WHERE table_2.rec_id=table_1.rec_id OR table_2.rec_id IS NULL" but this returns no records.

An Enum Field Using Values From Another Table
The first table, called genus, contains several fields, the important one in genus is name, and there are others about the individual plant types.

The second table 'plants' needs one field for the genus name, so that I can link tables on this. If there a way to make a foreign key from the genus table into an enum field on the second? My idea is that then, with phpmyadmin or similar I can just select the genus name from a list when entering new plant data.

Renumber Mysql Table Values
There are 100000 rows in a table, I need to renumber them from
1,3,6,8,11,14,21,55,888,1000,9999...99999
to
1,2,3,4,5,6,7,8,9,10,11,12,13,14...
etc
I also need to update an associated table, so its going to need to lock the tables, find the lowest available index in table1, then update table1 index, and then update table2 to use the same index as well, then unlock tables

What would be the procedure to do that?

Replace Some Username Values With The Users ID In A Different Table
I really can't figure this out. I want to replace some username values with the users ID in a different table.

The tables are

pictures
user (Example FRED)
picture (Example pic.gif)

users
id (Example 5233)
user (Example FRED)

What I want to do is replace the user column in pictures with the correct id from the users table

So in the pictures table, it would no longer be FRED it would be 5233

Is there a query I can run to do this?

I'd really appreciate some feedback

Query To Insert 2 Foreign Key Values In Table
I want to insert 2 foreign key values along with some other value into table ....

INSERT INTO Table (vars) VALUES(vals)
I am trying to use the following command:
INSERT INTO sr_main (originator,symreq) VALUES (A.Person,269);

Whenever I enter the command above I get the following error:
ERROR 1054 (42S22): Unknown column 'A.Person' in 'field list'

I am confused because the error refers to my _value_ 'A.Person' as a column!? Do string values need to be surrounded with quote marks of some type? I have already tried the obvious (to me) quote markers, e.g. ", '

The data is accepted if I use this command:
INSERT INTO sr_main (originator) VALUES (269);

I actually have a lot more fields and values than shown, and ideally would like to use the command type:

INSERT INTO tablename (field1,field2,field3) VALUES (1,2,3)

Code:

Counting Occurrences Of Values In Table Column.
I have two tables;

Table 1;

Agent_ID UserID First_Name Last_Name

1ShadShad Mortazavi
2Harry Harry Potter
Table 2;

Recording_IDAgent_ID Status GSM_File etc
11 000001.gsm
21 0 00002.gsm
32 100003.gsm
41 200004.gsm
51 100005.gsm
61 200006.gsm
72 100007.gsm

Status 0 = Red, 1 = Yellow and 2 = Green

I would like a query that returns the number of occurrences of Red, Yellow, Green against each agent

so the data returned would look something like this;

NameREDYellow Green
Shad Mortazavi 2 0 2
Harry Potter 0 2 0

I'm using MySQL version 3.23.58

I can do this programmatically in Perl with several query's; but this is CPU intensive. If I could get this in one query I it would save time.

Selecting Unique Values From A Table (NOT DISTINCT!)
Lets say we have a table that has the field photo_id and has values of it many times. For example 245 can exist any number of times (1, 5, 8, e.t.c.).

I want to select the values that exist in the table ONLY ONCE. Please note that i dont want to select each value once (using DISTINCT), that would return all the values that exist in the table.

For example lets say the table has the following values:

245
563
776
224
563
563
776
776
776
776

The query i want to make should return only the values 245 and 224 as 563 and 776 exist many times in that table.

Date/Time As A Default Values For A Table Column
I am new to mySQL, so this question might be simple.I want to add a default value to a column that is the current date/time. I am using the mySQL Administrator and will not allow me to use a function like CURRENT_TIMESTAMP() or NOW() as a default value. I used to do this with other databases (I always add a column to all of my tables called InsertDateTime and UpdateDateTime. It helps to track down data entry problems)

Updating Column With Sumned Values For Each Record In Table
I have most of the query formulated, but am stuck on the portion where I need to specify which records to update. I want to update all the records in the table. How can I specify the request_id to be the same in both the select and update statement?

Here's the query I'm working on:

Code:


update enhancementrequests2 set
hardBenefitEffortSavings = (SELECT hardBenefitEffortSavings + hardBenefitLaborSavings + hardBenefitHardwareSoftwareSavings
+ hardBenefitOtherSavings AS hbTotal
FROM enhancementrequests where request_id = 1), hardBenefitLaborSavings = NULL, hardBenefitHardwareSoftwareSavings = NULL,
hardBenefitOtherSavings = NULL
where request_id = 1



In my example I have specified that request_id = 1, but I want request_id to match each row of the table in turn. I hope that makes sense.

Load Null Values In Table Through LOAD FILE
I'M TRYING TO LOAD FILE WHICH HAS NULL VALUES FOR SOME COLUMNS AT THE FIRST ROW.IT Says "Incorrect Date Value for the column" as it has null values

Load Null Values In Table Through LOAD FILE
I'M TRYING TO LOAD FILE WHICH HAS NULL VALUES FOR SOME COLUMNS AT THE FIRST ROW . IT Says "Incorrect Date Value for the column" as it has null values.

Creating Field In Table To Sum Field Values
i was wondering if there was a way in mysql to have one record that will sum up all each field value(one record with each field having sum totals)? i have a table with over 60 statistical fields that i want to get the sum for.

Returning More That One Row From SP
I have 2 simple questions on stored procedures:

1) how do I return multiple rows?
DELIMITER //
CREATE PROCEDURE join_nary_relation() BEGIN
DECLARE c INT;

SELECT clanak_id FROM vidi_clanak_hardver INTO c;
END;
//
CALL join_nary_relation();

This fails:
ERROR 1172 (42000): Result consisted of more than one row

2) how do I return multiple columns?

As you see, I'd like to warp a SP around a SELECT in general case: a SELECT which returns a table with few rows and few columns. Is that possbile?

Returning Last Row
I need to return the last row in the table, I'm using auto_increment which is the 'priKey' column. 'beachName' is the name of the table , 'DATEOFFILE' is the column in the table that I need to return the last value for. Code:

Returning One Row
I'm working on a support ticket system. My two main tables are "tickets" and "ticket_messages". One ticket can have many ticket_messages. Ticket_messages have time stamps.
I need a query that will return all tickets with the ticket_message of the earliest time stamp, as opposed to pulling all ticket_messages for each ticket.
I'm having trouble digging up documentation or examples of this.
Here's a pseudo SQL statement that I'm trying to accomplish:

Code:


SELECT DISTINCT tm.subject, t.id, t.incident_date_time, t.create_date_time,
FROM tickets t
INNER JOIN ticket_messages tm ON tm.ticket_id = t.id
WHERE tm.id OF Min(tm.date_time_stamp)

AVG Returning 0, Not Null
I'm writing a script to allow visitors to rate articles on my site. Sometimes a question does not apply to that particular article or a person is just too lazy to fill out the entire form. Either way, I'm passing NULL to the MySQL database if the question was not filled out.

I want to do averages for each article for each question I ask. The problem is that I'm getting 0 only when I use AVG () even though the MySQL site says that should return a null if empty. It is not.

I have a "control group" table pulling the same data without using AVG. Of course, every vote is visible, but it's clear that null is working properly in that example.

Here's is a shortened version of my

PHP

$queryA = " SELECT URL , AVG(Vote) ,AVG(A1) , AVG(A2) , AVG(A3)FROM GalleriesGROUP BY URL";

$result = mysql_query($queryA) or die(mysql_error());

while($row = mysql_fetch_array($result)){
?>

<tr>

<td><?php echo $row['AVG(A1)']; ?>&nbsp;</td>
<td><?php echo $row['AVG(A2)']; ?>&nbsp;</td>
<td><?php echo $row['AVG(A3)']; ?>&nbsp;</td>

</tr>


<?
}
echo "</table>";


Any thoughts as to why AVG() would return 0 and not null when my database seams to be setup correctly?

Returning The Maximum Value From A SUM
Current query:

select sum(b) from db where dc=1 group by ba

returns:
510
764

I would like to just capture the MAX of this query.


Copyright 2005-08 www.BigResource.com, All rights reserved