
Counting Columns Catostrophes
If you saw my Simple Decimal Problem, this is the same database. I got the decimal fixed but then I tried to add a totals column.
drop database expenses2006;
create database expenses2006;
use expenses2006;
create table january (
id int not null auto_increment,
Date varchar(5),
Description varchar(50),
Office_Exp decimal(5,2),
Dues_Public decimal(5,2),
Business_Lunch decimal(5,2),
Conf_Cont_ED decimal(5,2),
Supplies_for_Prod decimal(5,2),
Small_Equip decimal(5,2),
Prom_Adv decimal(5,2),
Travel decimal(5,2),
Freight decimal(5,2),
Photo decimal(5,2),
Post decimal(5,2),
total decimal(6,2),
primary key(id)
);
insert into january (Date, Description) values ("0 0", "omit");
insert into january (Description, Office_Exp, Dues_Public, Business_Lunch, Conf_Cont_ED, Supplies_for_Prod, Small_Equip, Prom_Adv, Travel, Freight, Photo, Post, total)
values ("Totals", sum(january.Office_Exp), sum(january.Office_Exp), sum(january.Dues_Public), sum(january.Business_Lunch), sum(january.Conf_Cont_ED), sum(january.Office_Exp), sum(january.Office_Exp), sum(january.Supplies_for_Prod), sum(january.Small_Equip), sum(january.Prom_Adv), sum(january.Travel), sum(january.Freight), sum(january.Photo), sum(january.Post), sum(january.Office_Exp) + sum(january.Dues_Public) + sum(january.Business_Lunch) + sum(january.Conf_Cont_ED) + sum(january.Supplies_for_Prod) + sum(january.Small_Equip) + sum(january.Prom_Adv) + sum(january.Travel) + sum(january.Freight) + sum(january.Photo) + sum(january.Post));
I get an error saying column count doesn't match count at row 1.

In the second insert statement, you have 13 columns in the columns list but 16 items in the values list.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

Oh! Duhh! How could I not see that. Thanks. The world needs more people like you.

Now I get a invalid use of group error.

Could you post your code as it is now?
Chris.Martz.me
Some things Man was never meant to know. For everything else, there's Google.

Sorry,
Code:
drop database expenses2006;
create database expenses2006;
use expenses2006;
create table january (
id int not null auto_increment,
Date varchar(5),
Description varchar(50),
Office_Exp decimal(5,2),
Dues_Public decimal(5,2),
Business_Lunch decimal(5,2),
Conf_Cont_ED decimal(5,2),
Supplies_for_Prod decimal(5,2),
Small_Equip decimal(5,2),
Prom_Adv decimal(5,2),
Travel decimal(5,2),
Freight decimal(5,2),
Photo decimal(5,2),
Post decimal(5,2),
total decimal(6,2),
primary key(id)
);
insert into january (Date, Description) values ("0 0", "omit");
insert into january (Description, Office_Exp, Dues_Public, Business_Lunch, Conf_Cont_ED, Supplies_for_Prod, Small_Equip, Prom_Adv, Travel, Freight, Photo, Post, total)
values ("Totals", sum(january.Office_Exp), sum(january.Dues_Public), sum(january.Business_Lunch), sum(january.Conf_Cont_ED), sum(january.Supplies_for_Prod), sum(january.Small_Equip), sum(january.Prom_Adv), sum(january.Travel), sum(january.Freight), sum(january.Photo), sum(january.Post), sum(january.Office_Exp) + sum(january.Dues_Public) + sum(january.Business_Lunch) + sum(january.Conf_Cont_ED) + sum(january.Supplies_for_Prod) + sum(january.Small_Equip) + sum(january.Prom_Adv) + sum(january.Travel) + sum(january.Freight) + sum(january.Photo) + sum(january.Post));

In looking at your query, I can see that you are trying to insert data into the Description twice. Is this meant to be? Also, what is the exact error you are getting?
Chris.Martz.me
Some things Man was never meant to know. For everything else, there's Google.

 That's the error.
 You mean with the inserting the omit? Yes, that was just a test.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

