19:41
Subject: RE: Challenging query
On Thu, 2003-10-16 at 17:42, Jeff McKeon wrote:
Is there a way to generate a line number for a query return within the
returned rows??
For instance, if I return 5 rows from a query, is there a command or
function I can put in a query to add
I have a table that contains customer revenue information.
REVENUE TABLE:
Date, customer name, CustomerID, revenue, quantity
I need to create a query that will produce the following result
Year, Month, Customer1_rev, customer2_REV, customer3_rev, etc...
2002, 01, 0, $30.00, $15.00
I think the closest you can get is something like this:
SELECT YEAR(TheDate) AS Year,MONTH(TheDate) AS
Month,CustomerName,CustomerID,SUM(Revenue*Quantity) AS Revenue
FROM rev
GROUP BY Year, Month
ORDER BY Year,Month,CustomerID
A table with this data:
|
| row | blah | blew |
Jeff
-Original Message-
From: Gabriel Ricard [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 16, 2003 11:40 AM
To: Jeff McKeon
Cc: [EMAIL PROTECTED]
Subject: Re: Challenging query
I think the closest you can get is something like
Cc: [EMAIL PROTECTED]
Subject: Re: Challenging query
I think the closest you can get is something like this:
SELECT YEAR(TheDate) AS Year,MONTH(TheDate) AS
Month,CustomerName,CustomerID,SUM(Revenue*Quantity) AS
Revenue FROM rev GROUP BY Year, Month ORDER BY Year,Month,CustomerID
2391
[EMAIL PROTECTED]
There are 10 kinds of people in this world,
those who understand binary and those who don't (Unknown)
- Original Message -
From: Jeff McKeon [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, October 16, 2003 4:21 PM
Subject: Challenging query
I have a table
If you have a way to generate the query code dynamically
(e.g. using a loop in C, PHP etc.), you can build a query
using aliased tables :
SELECT YEAR(a.date) AS year, MONTH(a.date) AS month,
SUM(a.revenue) AS cust1_rev,
SUM(b.revenue) AS cust2_rev, SUM(c.revenue) AS cust3_rev
FROM
don't (Unknown)
- Original Message -
From: Jeff McKeon [EMAIL PROTECTED]
To: Rory McKinley [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Thursday, October 16, 2003 6:51 PM
Subject: RE: Challenging query
If you have a way to generate the query code dynamically
(e.g. using a loop in C
On Thu, 2003-10-16 at 17:42, Jeff McKeon wrote:
Is there a way to generate a line number for a query return within the
returned rows??
For instance, if I return 5 rows from a query, is there a command or
function I can put in a query to add a column that contains the row
number returned?
understand binary and those who don't (Unknown)
- Original Message -
From: Jeff McKeon [EMAIL PROTECTED]
To: Rory McKinley [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Thursday, October 16, 2003 6:51 PM
Subject: RE: Challenging query
If you have a way to generate the query code dynamically
with a
minimal SQL
query and minimal application code.
Jeff
-Original Message-
From: Gabriel Ricard [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 16, 2003 1:47 PM
To: Jeff McKeon; [EMAIL PROTECTED]
Subject: Re: Challenging query
Or you could just do one simply query
will be a simple multi-dimensional array with a
minimal SQL
query and minimal application code.
Jeff
-Original Message-
From: Gabriel Ricard [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 16, 2003 1:47 PM
To: Jeff McKeon; [EMAIL PROTECTED]
Subject: Re: Challenging query
Or you could just do one
:[EMAIL PROTECTED]
Sent: Thursday, October 16, 2003 2:11 PM
To: Jeff McKeon
Cc: [EMAIL PROTECTED]
Subject: Re: Challenging query
On Thursday, October 16, 2003, at 02:04 PM, Jeff McKeon wrote:
Do this query:
SELECT YEAR(TheDate) AS Year,MONTH(TheDate) AS
Month,CustomerName
.
Jeff
-Original Message-
From: Gabriel Ricard [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 16, 2003 2:11 PM
To: Jeff McKeon
Cc: [EMAIL PROTECTED]
Subject: Re: Challenging query
On Thursday, October 16, 2003, at 02:04 PM, Jeff McKeon wrote:
Do this query:
SELECT YEAR(TheDate
14 matches
Mail list logo