killyridols
Registered User.
- Local time
- Yesterday, 18:22
- Joined
- Jul 16, 2009
- Messages
- 22
Hello,
OK. So I have a table titled NANDAT with the columns: sample_id, shipcode, cruisenum, corenum, depth, data, art
I have a query written shown below:
SELECT DISTINCT sample_id, max(data) AS maxi, sum(data) AS summe
FROM NANDAT
WHERE art<>66 And art<>88 And art<>90 And art<>95 And art<>94 And art<>131 And art<>132 And art<>133
And sample_id Between 1 And 1200
GROUP BY sample_id;
However, I also want to include "art" as a column in the resulting table. I have tried to include it by typing this:
SELECT DISTINCT sample_id, max(data) AS maxi, sum(data) AS summe, art
FROM NANDAT
WHERE art<>66 And art<>88 And art<>90 And art<>95 And art<>94 And art<>131 And art<>132 And art<>133
And sample_id Between 1 And 1200
GROUP BY sample_id, art;
But, this doesn't work. It returns all of the results, not just one record per sample. I only want the record with the max 'data' to show up for each sample. But I also want a 'art' column to appear...
I'm stuck. Help??
Thank you!
OK. So I have a table titled NANDAT with the columns: sample_id, shipcode, cruisenum, corenum, depth, data, art
I have a query written shown below:
SELECT DISTINCT sample_id, max(data) AS maxi, sum(data) AS summe
FROM NANDAT
WHERE art<>66 And art<>88 And art<>90 And art<>95 And art<>94 And art<>131 And art<>132 And art<>133
And sample_id Between 1 And 1200
GROUP BY sample_id;
However, I also want to include "art" as a column in the resulting table. I have tried to include it by typing this:
SELECT DISTINCT sample_id, max(data) AS maxi, sum(data) AS summe, art
FROM NANDAT
WHERE art<>66 And art<>88 And art<>90 And art<>95 And art<>94 And art<>131 And art<>132 And art<>133
And sample_id Between 1 And 1200
GROUP BY sample_id, art;
But, this doesn't work. It returns all of the results, not just one record per sample. I only want the record with the max 'data' to show up for each sample. But I also want a 'art' column to appear...
I'm stuck. Help??
Thank you!