Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Error with this query

Author  Topic 

anchoredwisdom
Starting Member

22 Posts

Posted - 2009-08-27 : 09:48:08
can any one let me know whats the problem with this query


select t1.count(*) as X,t3.prod_desc,t2.count(*) as Y from sales_order_line_dim t1
inner join
sales_order_line_fct t2
on
t1.SALES_ORDER_LINE_KEY=t2.SALES_ORDER_LINE_KEY
inner join
prod_dim t3
on t3.prod_key=t2.prod_key
where
SALES_ORDER_LINE_CANCELLED_FLG = 'N'
and
SALES_ORDER_LINE_FULFILLED_FLG = 'Y'
and
t1.ACTIVE_FLAG ='Y'
and
ITM_TYPE_CODE in ('STANDARD', 'OPTION','INCLUDED')

group by prod_desc

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-08-27 : 10:13:26
it should be


select count(t1.yourcol) as X,t3.prod_desc,count(t2.yourcol) as Y from sales_order_line_dim t1
inner join
sales_order_line_fct t2
on
t1.SALES_ORDER_LINE_KEY=t2.SALES_ORDER_LINE_KEY
inner join
prod_dim t3
on t3.prod_key=t2.prod_key
where
SALES_ORDER_LINE_CANCELLED_FLG = 'N'
and
SALES_ORDER_LINE_FULFILLED_FLG = 'Y'
and
t1.ACTIVE_FLAG ='Y'
and
ITM_TYPE_CODE in ('STANDARD', 'OPTION','INCLUDED')

group by prod_desc

replace yourcol with actual column whose count you want
Go to Top of Page
   

- Advertisement -