Hi.
Use aliasing. Read carefully comments at
http://dev.mysql.com/doc/mysql/en/JOIN.html
Scott Hamm <[EMAIL PROTECTED]> wrote:
> My current database:
>
> mysql> SELECT
>-> Category.Category,
>-> GoalData.Reqvalue,
>-> GoalData.GoalMonth
>-> FROM
>-> goaldat
I FORGOT my GROUP BY (arrrgh!)
[EMAIL PROTECTED] wrote on 11/05/2004 09:28:20 AM:
> You were very close. What you are trying to produce is called a
cross-tab
> report or a pivot table (depending on who you ask)
>
> SELECT category.category,
> sum(if(goaldata.g
Michael Stassen wrote:
I can't seem to get to the online manual to check at the moment, but I'd
guess that dec is a reserved word.
DEC is short for DECIMAL. I should have remembered that. Sigh...
Michael
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscri
ght syntax to use near
'Dec,
I'm running 5.0.1-alpha-nt.
-Original Message-
From: Michael Stassen [mailto:[EMAIL PROTECTED]
Sent: Friday, November 05, 2004 9:42 AM
To: Scott Hamm
Cc: 'Mysql ' (E-mail)
Subject: Re: Column grouped by months
I believe you need a self join. Something
EMAIL PROTECTED]
Sent: Friday, November 05, 2004 9:31 AM
To: Scott Hamm
Cc: 'Mysql ' (E-mail)
Subject: Re: Column grouped by months
You're kind of mixing display formatting with data retrieval. MySQL is
a database, so it's display options for data are fairly limited, that's
-
From: Michael Stassen [mailto:[EMAIL PROTECTED]
Sent: Friday, November 05, 2004 9:42 AM
To: Scott Hamm
Cc: 'Mysql ' (E-mail)
Subject: Re: Column grouped by months
I believe you need a self join. Something like
SELECT
c.Category,
g11.Reqvalue AS Nov,
g12.Reqvalue AS Dec
FRO
I believe you need a self join. Something like
SELECT
c.Category,
g11.Reqvalue AS Nov,
g12.Reqvalue AS Dec
FROM
goaldata g11
JOIN goaldata g12
ON g11.catid = g12.catid AND g11.GoalMonth = 11 AND g12.GoalMonth = 12
JOIN category c ON g11.catid=c.id;
This might also work:
SELECT
You were very close. What you are trying to produce is called a cross-tab
report or a pivot table (depending on who you ask)
SELECT category.category,
sum(if(goaldata.goalmonth=11, reqvalue, 0)) as Nov,
sum(if(goaldata.goalmonth=12, reqvalue, 0)) as Dec
FROM
You're kind of mixing display formatting with data retrieval. MySQL is
a database, so it's display options for data are fairly limited, that's
usually the job of the front end. But, if you still want to push it to
format the way you requested, you need to do a join. Essentially,
you're going se
My current database:
mysql> SELECT
-> Category.Category,
-> GoalData.Reqvalue,
-> GoalData.GoalMonth
-> FROM
-> goaldata,
-> category
-> WHERE
-> goaldata.catid=category.id;
+-+--+---+
| Category
10 matches
Mail list logo