Click here to Skip to main content
15,891,703 members

Comments by Vijaydhas (Top 65 by date)

Vijaydhas 14-Mar-14 1:46am View    
Rating Interval 1 = 18

Rating Interval 2 = 4

Rating Interval 3 = 20

Rating Interval 4 = 5

Rating Interval 5 = 7

I have to extract like this..
Vijaydhas 11-Dec-13 13:10pm View    
It is also working..!!
Vijaydhas 11-Dec-13 13:04pm View    
Can You give me query for this? Please..!!

Write a query to show total amount ordered for each month of each year. Column needed are month, year and total amount.
Vijaydhas 11-Dec-13 12:56pm View    
Super Gi.. Super Gi.. Super Gi.. It's Working.. I only concentrate in sub query. But now only i realize it is possible without Sup query..

Thanks for instant reply..
Vijaydhas 11-Dec-13 12:48pm View    
Query:
Select Item,COUNT(quantity) AS TOTAL_ORDER from Items_Order Group By item having COUNT(quantity)>1 order by COUNT(quantity) desc;

O/P
Item Total_Order
Tent 3
Pen 2
Shoe 2

When i pass this query into sub query
select top 3 * FROM (Select Item AS ITEM,COUNT(quantity) AS TOTAL_ORDER from Items_Order Group By item having COUNT(quantity)>1) AS ord;

O/P
Item Total_Order
Pen 2
Shoe 2
Tent 3

Query:
Select Item,COUNT(quantity) AS TOTAL_ORDER from Items_Order Group By item order by COUNT(quantity) desc;

O/P

Item Total_Order
Tent 3
Shoe 2
Pen 2
Pogo stick 1
Raft 1
Ring 1
Shirt 1
Laptop 1
Mobile 1
Pant 1
Paper 1

Now i want pass this query to select top 3 rows. I pass like this:

select top 3 * FROM (Select Item AS ITEM,COUNT(quantity) AS TOTAL_ORDER from Items_Order Group By item order by COUNT(quantity) desc) AS ordered;

But it shows error:
Msg 1033, Level 15, State 1, Line 1

The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.