Advertisement

05.28.2008 at 08:22AM PDT, ID: 23438409
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

How to use ROUND function

Asked by ammartahir1978 in SQL Query Syntax, MS SQL Server

Tags: , ,

hi guys i have a query which is fine and give me results but i want to ROUND some of them so that i dont get long zero's in my VALUE/CUM VALUE/ROS etc how can i do itStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
SELECT     
          al.level_desc as DEPT_CATEGORY,  
          pm.alt_code1 as STYLE,  
          c.colour_desc as COLOUR,   
          pm.description as DESCRIPTION,  
          Pd.current_cp as CP,  
          pd.original_sp as ORIGINAL_SP,  
          pd.current_sp as CURRENT_SP,  
  
'STORE'=  (case when (Sum(ph.stock_units_free )) > 0 then count (distinct b.branch_code)-2 else 0 end),  
  
/************START OF RETAIL FIELDS************/  
SUM (CASE WHEN B.BRANCH_CODE IN ('001','002','003','004','005','006','007','008','009','010','011','012','014','015','016','017','018','019','020','021','022','023','024','025','026','027','028','029','030','031','032','033','034','035','207','20  
8','209','210','211','212','213','214','215') THEN ph.Sales_units - ph.REFND_units ELSE 0 END) as UNITS,  
          
'VALUE' =(SUM (CASE WHEN B.BRANCH_CODE IN ('001','002','003','004','005','006','007','008','009','010','011','012','014','015','016','017','018','019','020','021','022','023','024','025','026','027','028','029','030','031','032','033','034','035','207','
20  
8','209','210','211','212','213','214','215') THEN ph.sales_spvalue - ph.REFND_spvalue ELSE 0 END)),
  
'CUM_UNITS' = (SELECT SUM(phs.Sales_units - phs.REFND_units)  
                     FROM  product_history phs,    
                           product_master pms,    
                           product_detail pds,    
                           SIZES ss,    
                           colour cs,    
                           branch bs,    
                           anal_level als  
                     WHERE phs.week_selector BETWEEN 1200101 AND 1200117   
                           AND phs.sku_id = pds.sku_id    
                           AND pds.product_id = pms.prod_id    
                           AND als.j_code = pms.j_code_link    
                           AND als.level_no = 4    
                           AND ss.sizes_id = pds.sizes_id    
                           AND cs.colour_id = pds.colour_id    
                           AND bs.BRANCH_CODE IN ('000','001','002','003','004','005','006','007','008','009','010','011','012','014','015','016','017','018','019','020','021','022','023','024','025','026','027','028','029','030','031','032','033','034','
035','207','208','209','210','211','212','213','214','215')  
                           AND bs.branch_id = phs.branch_id    
                           --AND pms.alt_code1 like '%Q%'  
                           AND pm.alt_code1=pms.alt_code1  
                           AND c.colour_desc=cs.colour_desc  
                           AND al.level_desc=als.level_desc  
                           AND pd.original_sp=pds.original_sp  
                           AND pd.current_sp=pds.current_sp  
                           AND pm.description=pms.description  
                           AND Pd.current_cp=Pds.current_cp),
  
  
'CUM_VALUE' = (SELECT SUM(phss.sales_spvalue - phss.REFND_spvalue)  
                     FROM  product_history phss,    
                           product_master pmss,    
                           product_detail pdss,    
                           SIZES sss,    
                           colour css,    
                           branch bss,    
                           anal_level alss  
                     WHERE phss.week_selector BETWEEN 1200101 AND 1200117    
                           AND phss.sku_id = pdss.sku_id    
                           AND pdss.product_id = pmss.prod_id    
                           AND alss.j_code = pmss.j_code_link    
                           AND alss.level_no = 4    
                           AND sss.sizes_id = pdss.sizes_id    
                           AND css.colour_id = pdss.colour_id    
                           AND bss.BRANCH_CODE IN ('000','001','002','003','004','005','006','007','008','009','010','011','012','014','015','016','017','018','019','020','021','022','023','024','025','026','027','028','029','030','031','032','033','034',
'035','207','208','209','210','211','212','213','214','215')  
                           AND bss.branch_id = phss.branch_id    
                           --AND pmss.alt_code1 like '%Q%'  
                           AND pm.alt_code1=pmss.alt_code1  
                           AND c.colour_desc=css.colour_desc  
                           AND al.level_desc=alss.level_desc  
                           AND pd.original_sp=pdss.original_sp  
                           AND pd.current_sp=pdss.current_sp  
                           AND pm.description=pmss.description  
                           AND Pd.current_cp=Pdss.current_cp),  
  
  
  
  
  
  
'ROS' = CASE WHEN ( count (distinct b.branch_code)-2) = 0 then NULL  
else   
SUM (CASE WHEN B.BRANCH_CODE IN ('001','002','003','004','005','006','007','008','009','010','011','012','014','015','016','017','018','019','020','021','022','023','024','025','026','027','028','029','030','031','032','033','034','035','207','20  
8','209','210','211','212','213','214','215') THEN ph.Sales_units - ph.REFND_units ELSE 0 END)*1.00/(case when (Sum(ph.stock_units_free )) > 0 then count (distinct b.branch_code)-2 end) end,  
  
  
SUM (CASE WHEN B.BRANCH_CODE IN ('001','002','003','004','005','006','007','008','009','010','011','012','014','015','016','017',  
'018','019','020','021','022','023','024','025','026','027','028','029','030','031','032','033','034','035','207','208','209','210','211','212','213','214','215')   
THEN ph.stock_units_free + ph.stock_units_it + ph.stock_units_qc ELSE 0 END) as STORE_STK ,  
  
SUM (CASE WHEN b.branch_code IN ('000','001','002','003','004','005','006','007','008','009','010','011','012','014','015','016','017',  
'018','019','020','021','022','023','024','025','026','027','028','029','030','031','032','033','034','035','207','208','209','210','211','212','213','214','215')   
THEN ph.stock_units_free + ph.stock_units_it + ph.stock_units_qc ELSE 0 END) as TOTAL_RETAIL_STOCK,  
  
'STORE_COVER' =    
case when (SUM (CASE WHEN B.BRANCH_CODE IN ('001','002','003','004','005','006','007','008','009','010','011','012','014','015','016','017','018','019','020','021','022','023','024','025','026','027','028','029','030','031','032','033','034','035','207','
20  
8','209','210','211','212','213','214','215') THEN ph.Sales_units - ph.REFND_units ELSE 0 END) = 0) then 0 else(SUM (CASE WHEN b.branch_code IN ('001','002','003','004','005','006','007','008','009','010','011','012','014','015','016','017',  
'018','019','020','021','022','023','024','025','026','027','028','029','030','031','032','033','034','035','207','208','209','210','211','212','213','214','215')  
 THEN ph.stock_units_free + ph.stock_units_it + ph.stock_units_qc ELSE 0 END)) *1.00/(SUM (CASE WHEN B.BRANCH_CODE IN ('001','002','003','004','005','006','007','008','009','010','011','012','014','015','016','017','018','019','020','021','022','023','024
','025','026','027','028','029','030','031','032','033','034','035','207','20  
8','209','210','211','212','213','214','215') THEN ph.Sales_units - ph.REFND_units ELSE 0 END))end,  
  
'TOTAL_RETAIL_COVER' =    
case when (SUM (CASE WHEN B.BRANCH_CODE IN ('000','001','002','003','004','005','006','007','008','009','010','011','012','014','015','016','017','018','019','020','021','022','023','024','025','026','027','028','029','030','031','032','033','034','035','
207','20  
8','209','210','211','212','213','214','215') THEN ph.Sales_units - ph.REFND_units ELSE 0 END) = 0) then 0 else(SUM (CASE WHEN b.branch_code IN ('000','001','002','003','004','005','006','007','008','009','010','011','012','014','015','016','017',  
'018','019','020','021','022','023','024','025','026','027','028','029','030','031','032','033','034','035','207','208','209','210','211','212','213','214','215')  
 THEN ph.stock_units_free + ph.stock_units_it + ph.stock_units_qc ELSE 0 END)) *1.00/(SUM (CASE WHEN B.BRANCH_CODE IN ('001','002','003','004','005','006','007','008','009','010','011','012','014','015','016','017','018','019','020','021','022','023','024
','025','026','027','028','029','030','031','032','033','034','035','207','20  
8','209','210','211','212','213','214','215') THEN ph.Sales_units - ph.REFND_units ELSE 0 END))end  
  
  
  
    
FROM      product_history ph,    
          product_master pm,    
          product_detail pd,    
          SIZES s,    
          colour c,    
          branch b,    
          anal_level al    
    
WHERE     ph.week_selector = 1200117
          AND ph.sku_id = pd.sku_id    
          AND pd.product_id = pm.prod_id    
          AND al.j_code = pm.j_code_link    
          AND al.level_no = 4    
          AND s.sizes_id = pd.sizes_id    
          AND c.colour_id = pd.colour_id    
          AND b.branch_code IN ('000','999','001','002','003','004','005','006','007','008','009','010','011','012','014','015','016','017','018','019','020','021','022','023','024','025','026','027','028','029','030','031','032','033','034','035','207','
208',  
                                '209','210','211','212','213','214','215')    
          AND b.branch_id = ph.branch_id    
         --AND pm.alt_code1 like '%Q%'  
           
      
GROUP BY    
          pm.alt_code1,  
          c.colour_desc,   
          al.level_desc,  
          pd.original_sp,  
          pd.current_sp,  
          pm.description,  
          Pd.current_cp  
order by    
          pm.alt_code1
[+][-]05.28.2008 at 08:35AM PDT, ID: 21661384

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.28.2008 at 08:47AM PDT, ID: 21661509

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.28.2008 at 09:59AM PDT, ID: 21662159

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.28.2008 at 10:07AM PDT, ID: 21662219

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.28.2008 at 10:14PM PDT, ID: 21666525

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.29.2008 at 02:56AM PDT, ID: 21667590

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.29.2008 at 08:00AM PDT, ID: 21669746

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.03.2008 at 08:43AM PDT, ID: 21701553

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.03.2008 at 08:57AM PDT, ID: 21701717

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.03.2008 at 09:38AM PDT, ID: 21702130

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.03.2008 at 09:58AM PDT, ID: 21702294

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.03.2008 at 02:28PM PDT, ID: 21704705

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.03.2008 at 06:53PM PDT, ID: 21706082

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: SQL Query Syntax, MS SQL Server
Tags: Microsoft, SQL SERVER, 2000
Sign Up Now!
Solution Provided By: mark_wills
Participating Experts: 2
Solution Grade: A
 
 
[+][-]06.04.2008 at 04:45PM PDT, ID: 21715305

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.04.2008 at 05:26PM PDT, ID: 21715572

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628