Returning multiple aggregate functions as rows

Posted by SDLFunTimes on Stack Overflow See other posts from Stack Overflow or by SDLFunTimes
Published on 2010-04-22T06:46:08Z Indexed on 2010/04/22 8:53 UTC
Read the original article Hit count: 233

Filed under:
|
|

I need some help formulating a select statement. I need to select the total quantity shipped for each part with a distinct color. So the result should be a row with the color name and the total.

Here's my schema:

create table s
  ( sno    char(5)  not null,
    sname  char(20) not null,
    status smallint,
    city   char(15),
    primary key (sno)
  );
create table p
  ( pno    char(6)  not null,
    pname  char(20) not null,
    color  char(6),
    weight smallint,
    city   char(15),
    primary key (pno)
  );
create table sp
  ( sno    char(5)  not null,
    pno    char(6)  not null,
    qty    integer  not null,
   primary key (sno, pno)
  );

© Stack Overflow or respective owner

Related posts about mysql

Related posts about sql