Hello, I tend to learn from example and am used to powershell. If for instance in powershell I wanted to get-something and store it in a variable I could, then use it again in the same code. In this example of a table order items where there are order_num, quantity and item_prices how could I declare ordertotal as a variable then instead of repeating it again at "having sum", instead use the variable in its place? Can someone help show me an example of such a use of a variable that still lets me select the order_num, ordertotal and group them etc? I had hoped to simply replace in the "having section" the agg function with "ordertotal" which bombs out.
Thanks for the coaching! :) I am studying a "sql 2005 in 10min" book and practicing in sql express 2014. This is for my own learning so no rush thanks!
select order_num, sum(quantity*item_price) as ordertotal from orderitems group by order_num having sum(quantity*item_price) >=50 order by ordertotal;
- Edited by xxjergerxx 4 hours 17 minutes ago