Hi to all,
I created following table
---------------------------------------------------------------------------

create table Interiors(no integer, name varchar, type varchar, dateofstock datetime, price decimal(6,3), discount numeric(6,2))

-----------------------------------------------------------------------------

i want to solve these two queries.
1. Display the type, sum of price and average of discount by grouping type as 'baby cot'.
2. Display the type, maximum and minimum of price by grouping type as 'baby cot'.
I wrote following stmt.s for each resp.

----------------------------------------------------------------------------

1. select type, sum(price), avg(discount) from Interiors group by 'baby cot'.
2. select type, max(price), min(price) from Interiors group by 'baby cot'.

---------------------------------------------------------------------------

I got following error same for both like that 'type is not an aggregate fun. or it dont have GROUP BY' clause. What should I do for solving that queries.

Thanks & regards,
Pooja.

select type, sum(price), avg(discount) from interiors where name = 'baby cot' group by name

Not tested, YMMV.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.