soldier Posted April 20, 2015 Report Posted April 20, 2015 Given following DAILY_SALES table definition, please find out all stores that had more than 1 million dollar sales in the year of 2014. Please write the full SQL for the analysis, assuming Oracle database. DAILY_SALES table holds daily sales amount of each store and each customer; it has following 4 columns: STORE_NBR, CUSTOMER_NBR, TRANSACTION_DATE, SALES_AMOUNT e question ki effective gaa simple query ela rayaliiiii nenu idi anukuntunaaa select count(*) as All_STORES from ( select STORE_NBR, count(*) from DAILY_SALESwhere substr(TRANSACTION_DATE,1,4) = '2014' group by STORE_NBR having sum(SALES_AMOUNT) > 1000000 );
mtkr Posted April 20, 2015 Report Posted April 20, 2015 aa date col ea format lo undo thleyadu kaabatti instead of substring... convert tht to a date format and extract year frm it.
Yuvatha Posted April 20, 2015 Report Posted April 20, 2015 aa date col ea format lo undo thleyadu kaabatti instead of substring... convert tht to a date format and extract year frm it. nek calling thread esa :(
soldier Posted April 20, 2015 Author Report Posted April 20, 2015 aa date col ea format lo undo thleyadu kaabatti instead of substring... convert tht to a date format and extract year frm it. you mean..... Select store_nbr, sum(sales_amount) from daily_sales where TRANSACTION_DATE>='01-JAN-14' and TRANSACTION_DATE <='31-DEC-14' group by store_nbr having sum(sales_amount)>=1000000
prassanna Posted April 20, 2015 Report Posted April 20, 2015 you mean..... Select store_nbr, sum(sales_amount) from daily_sales where TRANSACTION_DATE>='01-JAN-14' and TRANSACTION_DATE <='31-DEC-14' group by store_nbr having sum(sales_amount)>=1000000 where extract(year from transaction_date) =2014
soldier Posted April 20, 2015 Author Report Posted April 20, 2015 where extract(year from transaction_date) =2014 Select store_nbr, sum(sales_amount) from daily_sales where extract(year from transaction_date)=2014 group by store_nbr having sum(sales_amount)>=1000000 ?????
prassanna Posted April 20, 2015 Report Posted April 20, 2015 Select store_nbr, sum(sales_amount) from daily_sales where extract(year from transaction_date)=2014 group by store_nbr having sum(sales_amount)>=1000000 ????? ya
mtkr Posted April 20, 2015 Report Posted April 20, 2015 WHERE EXTRACT(YEAR FROM TO_DATE(TRANSACTION_DATE, 'DD-MON-RR')) = 2014
soldier Posted April 20, 2015 Author Report Posted April 20, 2015 WHERE EXTRACT(YEAR FROM TO_DATE(TRANSACTION_DATE, 'DD-MON-RR')) = 2014 ok thanks baaaa
soldier Posted April 20, 2015 Author Report Posted April 20, 2015 proj em aina vachindaa!! ledhuu baa inkaa vetukutunaaa vendor gallu e questions adugutunaruu... SQL rasi pampisthee....vallaki inka effective gaa unadli antaaa !!!
Recommended Posts