Need help getting data out of Berkeley DB

Hi All
I have an old vrsion of Berkeley Db (about 5 years old I think) that we use at work for storing key value pairs. We use this to store ids for that data that we later load to a relational database. We have multiple files with key vaue pairs. One particular file is very large(11 GB) and has about 100million entries.
We are trying to migrate the data from Berkeley DB to a relational database. I was able to get the entries out of most files but this large file is givng trouble.
I can only get out about 26 million entries. I have tried Ruby and Perl to get the data out (our main application is in Ruby) and tried multiple approaches but all hit the limit at about 26.xx million records.
If anybody has experienced similar thing and knows a way to get the data out, your help is highly appreciated.
Thank
Harsh D.

Hi All
This is for Berkeley DB version that is at least 5 years old. I do not know the exact verion and do not know how to find one. This is not for the Java Edition or the XML edition.
Below is what I am doing in Ruby:
db = nil
options = { "set_pagesize" => 8 * 1024,
"set_cachesize" => [0, 8024 * 1024, 0]}
puts "starting to open db"
db = BDB::Btree.open(ARGV[0], nil, 0, options)
if(db.size < 1)
puts "\nNothing to dump; #{ARGV[0]} is empty."
end
puts "progressing with the db"
myoutput = ARGV[1]
puts "allocating the output file #{myoutput}"
f = File.open(myoutput,"w")
i = 0
iteration = 0
puts "starting to iterate the db"
db.each do |k, v|
a = k.inspect
b = v.inspect
f.puts "#{a}|#{b}"
i = i+1
if (i>1000000)
iteration = iteration + 1
puts "iteration #{iteration}"
i = 0
end
end
This only outputs about 26.xx million records. I am sures there are more than 50 million entries in the database.
I also tried some other approaches but nothing seems to work. I end up getting only 26.xx million entries in the output.
In some case, I managed to get it to output more records, but after 26.xx million, everything is output as duplicate entries so they are of no use to me.
The Ruby is 32 bit version. I tried this on Windows 7 (64 bit) and also on RedHat Linux 5 (64 bit version).
Thanks
Harsh
We ran db_stat on the ExpId database and below are the results
ExpId
53162 Btree magic number
8 Btree version number
Big-endian Byte order
Flags
2 Minimum keys per-page
8192 Underlying database page size
2031 Overflow key/data size
4 Number of levels in the tree
151M Number of unique keys in the tree (151263387)
151M Number of data items in the tree (151263387)
9014 Number of tree internal pages
24M Number of bytes free in tree internal pages (68% ff)
1304102 Number of tree leaf pages
3805M Number of bytes free in tree leaf pages (64% ff)
0 Number of tree duplicate pages
0 Number of bytes free in tree duplicate pages (0% ff)
0 Number of tree overflow pages
0 Number of bytes free in tree overflow pages (0% ff)
0 Number of empty pages
0 Number of pages on the free list

Similar Messages

  • Need help getting data out of a itemrenderer component

    I have a datagrid populated via a dataprovider (arrayCollection). No issue there
    I have a dateField Custom itemRenderer (as a component) and this is populated fine, so no issue there either.
    However I can't seem to find any way of getting the data out (it can be edited, so it is no longer the original data). I can get the original data, but not the new data.
    I can't use an event as there are hundreds of rows that I need to manipulate to write back to the database. I just want to get all the values as displayed in the datagrid.
    I just want to loop through the datagrid and pull out the data as entered in the itemrenderer component object. In debug mode I can see
    event --> itemrenderer --> [inherited] --> mycustomecomponent --> text. I just can't seem to get at it.
    Any Ideas. It's got to be simple and I am just missing it I guess.

    In your ItemRenderer, assign your data.yourDataFieldHere to the new value after editing is complete. This will allow you to then loop through the dataProvider in the main application and get all the values needed.
    function onEdit(evt:Event):void {
    data.yourDataField = evt.currentTarget.text; // Or use whatever property of the edited item you need here.
    Chris

  • I need to get data out of Oracle 8i??!!

    I am working for a company that is moving from one old application to a new application.
    The Old application is using Oracle 8i for a backend. I know SQL Server very well. However, I don't know Oracle.
    1) One guy on the forum helped me to find the SIDs and see the databases being run.
    2) I have also changed the password file and can now get in as internal.
    Great, but I need data.
    1) How can I get the data out of Oracle 8i?
    2) Is there a way to export the data to CSV or spreadsheet?
    3) There are 1400 tables with cryptic table names. How can I see the tables and their column names?
    (this is easy to do with SQL Server, but again, I am just starting to use Oracle).
    Thanks in advance for any and all help!!! This is crazy!

    Hello,
    No one likes a thread that goes on and on. I really appreciate those that try to help.
    I now this database is being used. However, we are trying to read the database and create reports before switching over to a new application.
    The database is in use.
    I've tried
    select table_name, column_name from user_tab_columns;
    I get over 15,000 rows of this
    TABLE_NAME COLUMN_NAME
    EXU81REFC ROWNER
    EXU81REFC RTNAME
    EXU81REFC CNAME
    EXU81REFC CNO
    EXU81REFC RCNO
    EXU81REFC ACTION
    EXU81REFC ENABLED
    EXU81REFC DEFER
    EXU81REFC PROPERTY
    EXU81REFC ROBJID
    EXU81REFC ROWNERID
    EXU81REFC REFTYPE
    EXU81REFI OBJID
    EXU81REFI OWNER
    EXU81REFI OWNERID
    EXU81REFI TNAME
    EXU81REFI ROWNER
    EXU81REFI RTNAME
    EXU81REFI CNAME
    EXU81REFI CNO
    EXU81REFI RCNO
    (none of which looks like user tables, but rather system tables)
    when I tried
    SELECT TABLE_NAME, NUM_ROWS FROM ALL_TABLES;
    I get over 1400 rows of this:
    TABLE_NAME NUM_ROWS
    CNBIL1
    CNBIL2
    CNBJR
    CNBJT
    CNBLC
    CNBLDE
    CNBLES
    CNBLK1
    CNBLK4
    CNBLLOG
    CNBLNET
    CNBLQ
    CNBLR
    CNBLR1
    CNBLRD
    CNBLRR
    CNBLRT
    CNBLRW
    CNBLTF5
    CNBLX
    CNBPC
    I've tried to do a select on a few table_names and I get "no rows selected".
    Isn't there a way in Oracle to see what tables have a rowcount > 0 and then get the table_names and column_names from those tables?
    I found the free download of TOAD, but not sure how much more that would help me than using SQL Plus at this stage of the game when I don't even see data. Maybe TOAD would help getting the data once I know where to look...I guess.
    Thanks for helping to straighten out with the confusion.

  • I have a cd stuck in my Macbook Pro. need help getting it out.

    so i was watching a movie, then i wanted to grab a bite to eat. i just pause the movie and closed my computer screen. then when i came back, the dvd did not want to play saying that "Supported Disc Not Available" and it would not eject when i hit the eject key button. NEED HELP ASAP

    Five ways to eject a stuck CD or DVD from the optical drive
    Ejecting the stuck disc can usually be done in one of the following ways:
      1. Restart the computer and after the chime press and hold down the
          left mouse button until the disc ejects.
      2. Press the Eject button on your keyboard.
      3. Click on the Eject button in the menubar.
      4. Press COMMAND-E.
      5. If none of the above work try this: Open the Terminal application in
          your Utilities folder. At the prompt enter or paste the following:
            /usr/bin/drutil eject
    If this fails then try this:
    Boot the computer into Single-user Mode. At the prompt enter the same command as used above. To restart the computer enter "reboot" at the prompt without quotes.

  • Need help getting people out of a time lapse

    Okay, this is what I want to do. I have a clip of three guys working on a graffiti artwork. Its 30 minutes long. I want to speed it to a time lapse, but I dont want to show the bodies of the three guys. So the final product would look like the graffiti forming by itself.
    The first thing I tried was to draw an animated 16-point garbage matte following the bodies while the layer below is a still frame of the final product. This will take me forever though. So I tried the time warp effect. I thought I could just blur out the bodies enough so that theyd just look like inconspicuous shadows moving around as the artwork forms. But rendering is a *****. I havent mastered the effect either. I couldnt figure out the proper settings so that the three guys would blur out enough so they wouldnt be too recognizable. (Ghosting doesnt really cut it either.)
    What would be a good idea to get this thing done?
    Really appreciate the help. Thanks!

    My suggestion would be to reshoot another project, but in time lapse using OnLocation. Figure out how long you want the clip to be, and from that how often you'll need to catch a frame. Say it works out to one frame every two minutes. So, every two minutes make sure the artists are out of frame.
    That's the only way I know of to really accomplish the desired end result.

  • Need help getting information out of array and into text/object files

    Im having alot of trouble with this i have the classes for the array, text reader and writer, and object reader and writer mostly done. I originally had a getInfo method in my object and text classes to input the data needed, but that wasnt how the instructor wanted. So my question is how do i take the infomation in the array in class studentarray and send that information to the text and object classes? I have looked online for an example and cant seem to find one that looks like it would work. I am pretty sure what i need will be put in the class StudentArray
    here is requirements i havent figured out how to implement
    - read student records from a �text� file
    - write student records into a �text� file (new data after sorting)
    - read student records from an �object� file
    - write student records into an �object� file (new data after sorting)
    I have sorting methods below in StudentArray just didnt post them
    public class StudentArray {
    private static Scanner input = new Scanner(System.in);
    private static student sArray[] = new student[5];
    public static void insert() throws NegativeIDException
    for(int i = 0; i < 5; i++)
    System.out.println("Please enter firstname:");
    String Fname = input.next();
    System.out.println("Please enter lastname:");
    String Lname = input.next();
    System.out.println("Please enter id:");
    int Id = 0;
    try
    Id = input.nextInt();
    NegativeIDException nide = new NegativeIDException("No negative number for id.");
    if(Id < 0)
    throw nide;
    scanner.nextLine();
    System.out.println("you must enter a positive number try again");
    catch(InputMismatchException ime)
    System.err.printf("\nException: %s\n", ime);
    scanner.nextLine();
    System.out.println("you must enter an integer try again");
    System.out.println("Please enter year admitted:");
    int Admitted = 0;
    try
    Admitted = input.nextInt();
    NegativeIDException nide = new NegativeIDException("No negative number for id.");
    if(Admitted < 0)
    throw nide;
    scanner.nextLine();
    System.out.println("you must enter an integer try again");
    catch(InputMismatchException ime)
    System.err.printf("\nException: %s\n", ime);
    scanner.nextLine();
    System.out.println("you must enter an integer try again");
    System.out.println("Please enter Gpa:");
    double Gpa = input.nextDouble();
    int t = 0;
              int q = 0;
              System.out.println("Please select your track");
                   System.out.println("1 for doctoral student");
                   System.out.println("2 for graduate student");
                   System.out.println("3 for major student");
                   System.out.println("4 for minor student");
                   t = input.nextInt();
                   if (t == 1)
                             System.out.println( "Please select your doctoral topic");
                             System.out.println("1 for Video Games");     
                             System.out.println("2 for CPU History");     
                             System.out.println("3 for Other");     
                             int c = input.nextInt();                         
                             String diss = "";
                             if (c == 1)
                                  diss = "Video Games";     
                             else if (c == 2)
                                  diss = "CPU History";
                             else if (c == 3)
                                  diss = "Other";
                             sArray[i] = new CSDoctStudent(Fname, Lname, Id, Admitted, Gpa, diss);
                             q++;                              
                        else if (t == 2)
                        System.out.println( "Please enter the number for your graduate course");
                        System.out.println("1 for Software Engineering");     
                        System.out.println("2 for Theory");     
                        System.out.println("3 for Other");     
                        int b = input.nextInt();
                        String Theory = "";
                        if (b == 1)
                             Theory = "Software Engineering";     
                        else if (b == 2)
                             Theory = "Theory";
                        else if (b == 3)
                             Theory = "Other";
                        sArray[i] = new CsGradStudent(Fname, Lname, Id, Admitted, Gpa, Theory);
                   q++;     
                        else if (t == 3)
                             System.out.println( "Please enter the number for your major course");
                             System.out.println("1 for Hardware");     
                             System.out.println("2 for IS");     
                             System.out.println("3 for Theory");     
                             int m = input.nextInt();
                             String track = "";
                             if (m == 1)
                             track = "Hardware";
                        else if (m == 2)
                             track = "IS";
                        else if (m == 3)
                             track = "Theory";
                             sArray[i] = new CSMajorStudent(Fname, Lname, Id, Admitted, Gpa, track);
                             q++;     
                   else if ( t == 4)
                             System.out.println( "Please enter the number for your minor course");
                             System.out.println("1 for Computer Application");     
                             System.out.println("2 for Multimedia");     
                             System.out.println("3 for Web Technology");
                             int d = input.nextInt();
                             String Hardware = "";
                             if (d == 1)
                                  Hardware = "Computer Application";     
                             else if (d == 2)
                                  Hardware = "Multimedia";
                             else if (d == 3)
                                  Hardware = "Web Technology";
                             sArray[i] = new CSMinorStudent(Fname, Lname, Id, Admitted, Gpa, Hardware);
                             q++;     
                   else;
    sArray= new student(Fname,Lname,Id,Admitted, Gpa);
    //trying to write it to a text file with this
    import java.io.PrintWriter;
    import java.util.Scanner;
    import java.io.File;
    import java.io.FileNotFoundException;
    public class TStream {
    private Scanner input = null;
    private PrintWriter output = null;
    private student [] sArray = new student[5];
    public TStream()
    public void write()
    try
    output = new PrintWriter("tdatabase.txt");
    for(int i = 0; i < 5; i++)
    output.print(sArray[i].getFname() + "\t");
    output.print(sArray[i].getLname() + "\t");
    output.print(sArray[i].getId() + "\t");
    output.print(sArray[i].getAdmitted() + "\t");
    output.print(sArray[i].getGpa() + "\t");
    output.println();
    output.close();
    catch(FileNotFoundException fnfe)
    System.err.printf("\nException: %s\n", fnfe);
    System.out.println("Can not open this file.\n");
    public void read()
    try
    input = new Scanner(new File("tdatabase.txt"));
    for(int i = 0; i < 5; i++)
    String Fname = input.next();
    String Lname = input.next();
    int Id = input.nextInt();
    int Admitted = input.nextInt();
    double Gpa = input.nextDouble();
    sArray[i] = new student(Fname,Lname,Id,Admitted,Gpa);
    input.close();
    catch(FileNotFoundException fnfe)
    System.err.printf("\nException: %s\n", fnfe);
    System.out.println("Can not open this file.\n");

    Use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.

  • [Intel] Need help getting more out of my prescott 2.4a (pt880neofsr)

    Hello all, first post here
    Anyways, I have be able to get my prescott 2.4a to 3.3ghz stable, with everything stock, except for memory timings set to manuel (3-3-3-8 200mhz, but running at 183fsb on micron chips, doing a manuel 3-3-3-8 i was able to get my system stable, the chips are rated for 3-3-3-8 200mhz)
    So far so good, but i was hoping to get more, like hitting the 200fsb barrier.
    Im running the 1.6 bios.  I tried adjesting the voltages on the cpu, but i got a no go, no boot.  I can't figure out what else it could be.  Any suggestions would be greatly appreceative. (like more cooling?)
    My system specs is as follows:
    Intel Prescott Pentium 4 2.4a @ 3.3ghz
    MSI PT880 Neo-FSR (with 1.6 bios)
    Enermax EG465P-VE 460watt powersupply +3.3v-35amp / +5v-35amp / +12v-33amp
    Western Digital 80gig 8mb cache
    9800pro flashed to XT speeds
    Audigy 1 using Audigy 2 driver set

    Thats's allready a nice overclock 
    Maybe if you get the temps lower, u might be able to squeese out a little more.
    Raising the vmem might help you get your memory to CAS 2,5 or even 2.

  • Anyone here have an iSee case? Need help getting iPod out of it!!

    Can't get the iPod out of the case! Is there a secret to this? Need to charge and update and probably shouldn't have it in the case for that.

    Let you N router be connected to your Modem, Just you need to make some changes on your N router to get a good speed on your computers.Just follow this step, this will work out.
    Open an Internet Explorer browser page.In the address bar type - 192.168.1.1 Leave username blank & in password use admin in lower case...or Wireless Settings, please do the following : -
    Click on the Wireless tab-
    -Here select manual configuration...Wireless Network mode should be mixed...
    -Provide a unique name in the Wireless Network Name (SSID) box in order to differentiate your network from your neighbours network...
    - Set the Radio Band to Standard-20MHz and change the standard channel to 11-2.462GHz...
    - And wireless SSID broadcast should be Enabled and then click on save settings...
    Please make a note of Wireless Network Name (SSID) as this is the Network Identifier...
    For Wireless Security : -
    Click on the Sub tab under Wireless > Wireless Security...
    Change the Wireless security mode to WEP, Encryption should be 64 bits.Leave the passphrase blank, don't type in anything...
    Under WEP Key 1 type in any 10 numbers please(numbers only and no letters) and click on save settings...
    Please make a note of WEP Key 1 as this is the Security Key for the Wireless Network.
    Click on Advanced Wireless-
    settings>>Change the Beacon Interval to 75 >>Change the Fragmentation...
    Threshold to 2304 Change the RTS Threshold to 2307 >>Click on "Save Settings"...
    Now see if you can locate your Wireless Network and attempt to connect...

  • NEED HELP GETTING SOMETHING OUT OF MY DEAD IBOOK

    ok so ive had my beautiful ibook g4 for about 5 years, and about a week ago i sent it to get fixed cause it was acting weird and it was because my hard drive is absolutely dead. but that isnt my question... I didnt get a chance to back up my stuff and i dont really care about anything in there except some pictures... and I was wondering if you guys could give me options on what to do
    but i also have to tell you this:
    my ibook wont turn on.
    the little gray apple with the white background pops up and then 4 minutes later or so it just turns off immedietly.
    so I really dont know what to do...
    i did the hard drive test to see if it could react and nothing- and when i tried to reinstall mac os x, and put the option of keeping all the info i got the kernel attack.
    please help me!
    Cristo

    Go to a certified Apple Tech or Apple Store and have them extract the information from the HD to another source. They'll pull the drive, put it in an external housing and extract from there.

  • Need to Get Data From Siebel On Demand ( I am new to Siebel Please Help)

    Hi All,
    I have a project in which i need to get data from Siebel On Demand and Automate this process.
    I have downloaded the Custom WSDL file and the Schema file from Oracle Siebel On Demand. I am using IDE WSAD and when i import these files into WSAD i am getting an error stating the schema definitions are wrong. Can anyone help me.....
    I need to complete it asap....
    Edited by: user491578 on Nov 11, 2008 6:50 PM

    You should probably ask Advantech. This question really has nothing to do with LabVIEW SE or NI-ELVIS. You could try posting to the LabVIEW board but there have only ever been two posts regarding 'advantech 4716'.

  • Okay so I have a new ipod touch...but I need to get music out of my old nano to my itues w/out wiping out my old nano...how do i do this? new laptop so itues is new...please help

    okay so I have a new ipod touch...but I need to get music out of my old nano to my itues w/out wiping out my old nano...how do i do this? new laptop so itues is new...please help

    You need to authorize your new computer in iTunes with the same account that is synced to your nano (and old iTunes)
    In the menu bar click Store >> Authorize This Computer…
    This will allow your purchased music to be re-downloaded from iTunes and played on your new computer.
    If you did not purchase the music through iTunes, you may need a third-party program to get the music off the nano. However, It is much easier (by far) to move your old library from your old computer to the new one if you still have access to the old files. iTunes will not transfer music from your nano to the computer. It is a one-way sync.
    If you still have access to your old files, search google for how to transfer an itunes library, and follow someones instructions. It's not too complicated. You may want to specify mac to pc, pc to mac, mac to mac, or pc to pc, as the instructions will change.

  • Getting data out of Oracle to SQL Server 2005

    Hello,
    I am new in Oracle and I have this question.
    I need to transfer lots of data frequently at day from a large Oracle DB to a SQL Server 2005 Database.
    Could you tell me what tools (including PL/SQL) ORACLE offers to reach this goal?
    *.Dat files are still a way to perform this job or other method more performance (quickly and efficiently) are available?
    Using MS SSIS is better ?
    Thank for your help

    I've done getting data out of Oracle to MS Access DB using heterogenous servicing.I hope that that would be the best way for your case too..
    Check this out.
    http://www.datadirect.com/developer/odbc/oracle_heterogeneous/index.ssp
    Regards,
    Bhagat

  • Need Help with Dates

    I am printing a calendar and certain events will be helds on certain dates.
    One can edit the event if it has not passed the date. Events in the past can be viewed but not edited.
    When I query the database the date must be formatted dd-MMM-yy
    I am able to get today's date by doing this:
    java.util.Date today = new java.util.Date();
    String formatString = "dd-MMM-yy";
    SimpleDateFormat sdf = new SimpleDateFormat(formatString);
    String today_str = sdf.format(today);
    My code for printing the calendar: I left out some of the table formatting in the JSP page.
    GregorianCalendar d = new GregorianCalendar();
    int today = d.get(Calendar.DAY_OF_MONTH);
    int month = d.get(Calendar.MONTH);
    d.set(Calendar.DAY_OF_MONTH,1);
    int weekday = d.get(Calendar.DAY_OF_WEEK);
    for(int i = Calendar.SUNDAY; i < weekday; i++)
    out.print("<td> </td>");
    do {
    int day = d.get(Calendar.DAY_OF_MONTH);
    out.print("<td>" + day + "</td>");
    String formatString = "dd-MMM-yy";
    SimpleDateFormat sdf = new SimpleDateFormat(formatString);
    //if(event exists on this day
    // Get results
    // print link for viewing
    // if (after today) print link for edit
    if(weekday == Calendar.SATURDAY)
    out.println("</tr><tr valign=top>");
    d.add(Calendar.DAY_OF_MONTH,1);
    weekday = d.get(Calendar.DAY_OF_WEEK);
    } while(d.get(Calendar.MONTH) == month);
    if(weekday != Calendar.SUNDAY)
    System.out.println();
    The part I need help on is this:
    //if(event exists on this day
    // Get results
    // print link for viewing
    // if (after today) print link for edit
    I'm looping through each day of the month to print the days. I have the month, day, year as integers. How can I create a date object out of that and compare it to today's date to test if it's before or after today???
    All the function in the Date class that I think would do this have been deprecated.

    Need Help with Dates
    Here is some information about dates:
    There are many edible palm fruits, and one of the most widespread and favored of these is the data (Phoenix dactylifera). Dates were cultivated in ancient land from Mesopotamia to prehistoric Egypt, possibly as early as 6000 B.C. Then--as now--dates were a staple for the natives of those dry regions. Much later, Arabs spread dates around northern Africa, and dates were introduced into California by the Spaniards in 1765, around Mission San Ignacio.
    The date prefers dry, hot climates, because date fruits are injured at temperatures of 20 degrees F, and the damp climate of the California coast was not favorable for fruit production. In the mid-1800s, the date industry developed in California's hot interior valleys and in Arizona. Now the date industry in the United States is localized mostly in the Coachella Valley, where the sandy soils permit the plants to be deeply irrigated. Today the new varieties, mostly introduced in this century, produce about 40 million pounds of dates per annum, or over 60% of the dates consumed in this country. The rest are imported mainly from Persia. According to one survey, about one million people are engaged entirely in date palm cultivation worldwide.
    Hope that helps.

  • TS1398 I need help getting connected to our home wifi.

    I need help getting connected to our home wifi. I've reset network settings, iPhone, and router  but the error "unable to join network" keeps coming up. I also double checked the password. Please help

    Other possibilities:
    Your router firmware is out of date. Check the manufacturer's website for an update
    You have MAC (Media Access Control) filtering enabled on the router, that restricts access to "known" devices and the new iPhone is not on the table of known devices
    Your router has a setting limiting the number of simultaneous allowed devices
    Your routers SSID ("name") is still the default (e.g., LINKSYS, DLINK, NETGEAR, etc). Your phone has encountered other routers with the same name as you have traveled, and the phone is confused as to which router is the real one. If your router's name is still the default you should change it.

  • Need help getting YTD total

    I've got a period to date report with following columns:
    week1 tots, week2 tots, week3 tots, week4 tots, week5 tot, period-to-date tots, year-to-date tots
    I have a SELECT statement which totals data for the entire year and separates current period totals
    by grouping on the week_nbr . Any date between beginning of year and the end of the previous period will be week 0
    The Select statement retursn 6 rows: 1 for each week in period and one with week_nbr = 0 which represents the totals from the beginning of year
    to the end of the previous period.
    the select statement returns the data correctly . I need help getting the YTD total for (weeks 1 - 5) + (totals for week 0) for each column.
    This means that I will have a 7th record containing the YTD totals. ( I am not concerned with the PTD totals)
    I tried sum by partition but complex decode statement gave me problems.
      CREATE TABLE PERIOD_DATA
       (     "HOT_DOG_STAND_ID" NUMBER NOT NULL ENABLE,
         "WEEK_DATE" DATE,
         "NET_SALES2" NUMBER,
         "BUNS24434" NUMBER,
         "PICKELS_AW38" NUMBER,
         "MUSTARD_TB56" NUMBER,
         "CHICKENHEADS33" NUMBER,
         "PIECES_SOLD34" NUMBER,
         "SCRAPS35" NUMBER,
         "PIECES_UNACCOUNTED" NUMBER
    REM INSERTING into PERIOD_DATA
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('29-DEC-08','DD-MON-RR HH.MI.SSXFF AM'),14301.39,13951.26,3431.13,0,3680,2484,378,818);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('05-JAN-09','DD-MON-RR HH.MI.SSXFF AM'),14651.37,14651.37,3249.55,0,3200,2419,505,276);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('12-JAN-09','DD-MON-RR HH.MI.SSXFF AM'),14169.89,14169.89,2463.53,0,3136,2080,474,582);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('19-JAN-09','DD-MON-RR HH.MI.SSXFF AM'),15864.46,15864.46,3245.49,0,3472,2764,475,233);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('26-JAN-09','DD-MON-RR HH.MI.SSXFF AM'),15961.2,15916.23,3395.51,0,3648,2838,392,418);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('02-FEB-09','DD-MON-RR HH.MI.SSXFF AM'),19066.4,19066.4,4165.07,0,4336,3682,333,321);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('09-FEB-09','DD-MON-RR HH.MI.SSXFF AM'),18415.74,18415.74,4024.74,0,4032,3365,482,185);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('16-FEB-09','DD-MON-RR HH.MI.SSXFF AM'),18014,17849,3486.33,0,3840,3238,374,228);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('23-FEB-09','DD-MON-RR HH.MI.SSXFF AM'),18671.09,18626.12,3729.42,0,3888,2970,353,565);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('02-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),17636,17636,3815,0,3424,2840,490,94);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('09-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),17235.52,17145.58,3897.42,0,3504,2928,421,155);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('16-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),15989.27,15989.27,3372.95,0,3728,3051,369,308);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('23-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),19067.69,18960.41,4152.6,0,4048,3293,442,313);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('30-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),18717.99,18717.99,3923.69,0,4408,3219,593,596);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('06-APR-09','DD-MON-RR HH.MI.SSXFF AM'),17335.16,17335.16,3769.08,0,3928,2997,514,417);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('13-APR-09','DD-MON-RR HH.MI.SSXFF AM'),18967.39,18967.39,4157.76,0,4144,2991,527,626);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('20-APR-09','DD-MON-RR HH.MI.SSXFF AM'),23090.88,23090.88,4427.96,0,5544,4493,560,491);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('27-APR-09','DD-MON-RR HH.MI.SSXFF AM'),24197.98,24132.99,4248.66,0,6680,5190,606,884);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('04-MAY-09','DD-MON-RR HH.MI.SSXFF AM'),20202.21,20137.22,3714.68,0,7052,6170,422,460);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('11-MAY-09','DD-MON-RR HH.MI.SSXFF AM'),18514.48,18514.48,3266.06,0,5508,4178,571,759);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('18-MAY-09','DD-MON-RR HH.MI.SSXFF AM'),18678.68,18678.68,3814.07,0,5824,4345,633,846);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('25-MAY-09','DD-MON-RR HH.MI.SSXFF AM'),17937.18,17937.18,3051.52,0,4844,4986,529,-671);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('01-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),17445.75,17445.75,3079.91,0,5028,4810,656,-438);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('08-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),17327.88,17327.88,3263.29,0,6112,4674,672,766);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('15-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),17241.72,16937.33,3328.27,0,5792,4490,567,735);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('22-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),16625.83,16625.83,3485.18,0,5408,4319,761,328);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('29-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),17002.84,17002.84,3091.09,0,5664,4369,544,751);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('06-JUL-09','DD-MON-RR HH.MI.SSXFF AM'),16339.19,16274.2,3075.3,0,4784,3440,697,647);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('13-JUL-09','DD-MON-RR HH.MI.SSXFF AM'),17165.12,16885.14,3458.03,0,4320,3296,640,384);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('20-JUL-09','DD-MON-RR HH.MI.SSXFF AM'),17029.77,16899.79,3198.91,0,4448,3449,645,354);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('27-JUL-09','DD-MON-RR HH.MI.SSXFF AM'),16596.89,16596.89,3015.54,0,4624,3288,665,671);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('03-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),16468.58,16468.58,2981.35,0,2224,3495,564,-1835);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('10-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),18625.48,18550.5,3524.44,0,4856,3482,578,796);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('17-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),24538.54,24323.55,5580.71,0,5260,3771,608,881);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('24-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),18081.37,18081.37,3533.45,0,5980,3080,553,2347);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('31-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),17183.25,17183.25,3487.12,0,2544,3262,615,-1333);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('07-SEP-09','DD-MON-RR HH.MI.SSXFF AM'),17688.41,17575.29,3424.17,0,4800,3480,591,729);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('14-SEP-09','DD-MON-RR HH.MI.SSXFF AM'),18211.29,18211.29,3806.32,0,3968,3104,527,337);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('21-SEP-09','DD-MON-RR HH.MI.SSXFF AM'),16809.21,16744.22,3014.61,0,4128,3124,710,294);
    SELECT HOT_DOG_STAND_ID
    , DECODE(TRUNC(week_date , 'iw') ,
             to_date('24-AUG-09' , 'dd-mon-rr') , 1 ,
             to_date('24-AUG-09' , 'dd-mon-rr') + 7 , 2 ,
             to_date('24-AUG-09' , 'dd-mon-rr') + 14 , 3 ,
             to_date('24-AUG-09' , 'dd-mon-rr') + 21 , 4 ,
             to_date('24-AUG-09' , 'dd-mon-rr') + 28 , 5 , 0) AS week_nbr
    , SUM(NET_SALES2)                                                                                                                                                                                                                                                     AS net_sales2
    , SUM(BUNS24434 ) BUNS24434
    , SUM(PICKELS_AW38) PICKELS_AW38
    , SUM(MUSTARD_TB56) MUSTARD_TB56
    , SUM(CHICKENHEADS33) CHICKENHEADS33
    , SUM(PIECES_SOLD34) PIECES_SOLD34
    , SUM(SCRAPS35) SCRAPS35
    , SUM(PIECES_UNACCOUNTED) * - 1 PIECES_UNACCOUNTED
       /*--== Head average  net_sales / chickenusage*/
    , CASE
          WHEN NVL( SUM(ChickenHeads33) / 8 , 0) = 0 THEN 0
          ELSE ROUND(SUM(net_sales2) / ( SUM(ChickenHeads33) / 8 ) , 2)
       END AS Head_average
       /*--=== Efficiency =   (ChickenUsage  - scrappedDiv8 - unaccountedDiv8) / ChickenUsage)  * 100*/
    , CASE
          WHEN NVL(SUM(ChickenHeads33) / 8 , 0) = 0 THEN 0
          ELSE ROUND((((SUM(ChickenHeads33) / 8 ) - ( SUM(scraps35) / 8 ) - (SUM(pieces_unaccounted) / 8 )) / (SUM(ChickenHeads33) / 8 )) * 100 , 2)
       END AS efficiency
    FROM period_data per
    WHERE week_DATE BETWEEN TRUNC(TO_DATE( '24-AUG-09' , 'DD-MON-YY') , 'IY') AND TRUNC(TO_DATE( '24-AUG-09' , 'DD-MON-YY') , 'IW') + 6 + 7 * 4
    GROUP BY hot_dog_stand_id
    , DECODE(TRUNC(week_date , 'iw') ,
          to_date('24-AUG-09' , 'dd-mon-rr') , 1 ,
          to_date('24-AUG-09' , 'dd-mon-rr') + 7 , 2 ,
          to_date('24-AUG-09' , 'dd-mon-rr') + 14 , 3 ,
          to_date('24-AUG-09' , 'dd-mon-rr') + 21 , 4 ,
          to_date('24-AUG-09' , 'dd-mon-rr') + 28 , 5 ,
          0)
    ORDER BY DECODE(TRUNC(week_date , 'iw') , to_date('24-AUG-09' , 'dd-mon-rr') , 1 , to_date('24-AUG-09' , 'dd-mon-rr') + 7 , 2 , to_date('24-AUG-09' , 'dd-mon-rr') + 14 , 3 , to_date('24-AUG-09' , 'dd-mon-rr') + 21 , 4 , to_date('24-AUG-09' , 'dd-mon-rr') + 28 , 5 , 0);The expected results will be:
    HOT_DOG_STAND_ID       WEEK_NBR               NET_SALES2             BUNS24434              PICKELS_AW38           MUSTARD_TB56           CHICKENHEADS33         PIECES_SOLD34          SCRAPS35               PIECES_UNACCOUNTED     HEAD_AVERAGE           EFFICIENCY            
    141                    7                      697067.09              694887.4               139149.91              0                      175808                 139454                 21036                  15318                  31.72                  79.32                  You can get these dame results by running endpot-to-endpoint query:
    SELECT  HOT_DOG_STAND_ID
         , max(7) as week_nbr
         ,sum(NET_SALES2)      net_sales2
          ,sum(BUNS24434 )        BUNS24434
          ,sum(PICKELS_AW38)      PICKELS_AW38
          ,sum(MUSTARD_TB56)     MUSTARD_TB56
          ,sum(CHICKENHEADS33)   CHICKENHEADS33
          ,sum(PIECES_SOLD34)    PIECES_SOLD34
          ,sum(SCRAPS35)         SCRAPS35
          ,sum(PIECES_UNACCOUNTED)   PIECES_UNACCOUNTED
        ---===== Copied code from outer query
              --==  net_sales / chickenusage 
                      ,   CASE
                             WHEN NVL( sum(ChickenHeads33) / 8    ,0)  = 0 then 0
                             ELSE ROUND(sum(net_sales2)/   ( sum(ChickenHeads33) / 8    ) , 2)
                          END as Head_average
                        --=== Efficiency =   (ChickenUsage  - scrappedDiv8 - unaccountedDiv8) / ChickenUsage)  * 100
                        ,   CASE
                                  WHEN NVL(sum(ChickenHeads33) / 8    ,0)  = 0 then 0
                                  ELSE   ROUND((((sum(ChickenHeads33) / 8 )  - ( sum(scraps35) / 8 ) - (sum(pieces_unaccounted) / 8 )) / (sum(ChickenHeads33) / 8 )) * 100, 2)
                          END as efficiency  
    from period_data
    WHERE week_DATE BETWEEN TRUNC(TO_DATE( '24-AUG-09' ,'DD-MON-YY'), 'IY') AND TO_DATE( '27-sep-09' ,'DD-MON-YY')
    group by hot_dog_stand_id;Thanks In Advance

    Hi,
    Welcome to the forum!
    Thanks for posting the CREATE TABLE and INSERT statements; that's very helpful. You could teach something to some people who have been using this forum for years (except that nobody can teach them).
    user12335325 wrote:
    The expected results will be:
    HOT_DOG_STAND_ID       WEEK_NBR               NET_SALES2             BUNS24434              PICKELS_AW38           MUSTARD_TB56           CHICKENHEADS33         PIECES_SOLD34          SCRAPS35               PIECES_UNACCOUNTED     HEAD_AVERAGE           EFFICIENCY            
    141                    7                      697067.09              694887.4               139149.91              0                      175808                 139454                 21036                  15318                  31.72                  79.32                 
    Do you mean the expected results will include the row above, and that the results will be this row along with the 6 rows you're already getting? (If you wanted just that one row, I suppose you would just run your second query.)
    That sound like a job for ROLLUP.
    VARIABLE   start_date     VARCHAR2 (11);
    EXEC         :start_date  := '24-AUG-2009';
         SELECT  HOT_DOG_STAND_ID
         ,      NVL (CASE
                   WHEN  week_date >= TO_DATE( :start_date, 'DD-MON-YYYY')
                   AND   week_date <  TO_DATE( :start_date, 'DD-MON-YYYY') + 35
                   THEN  1 + FLOOR ( (week_date - TO_DATE( :start_date, 'DD-MON-YYYY'))
                                             / 7
                   ELSE  0
                      END
                 , 7
                 )          AS week_nbr
    , SUM(NET_SALES2)                                                                                                                                                                                                                                                     AS net_sales2
    , SUM(BUNS24434 ) BUNS24434
    , SUM(PICKELS_AW38) PICKELS_AW38
    , SUM(MUSTARD_TB56) MUSTARD_TB56
    , SUM(CHICKENHEADS33) CHICKENHEADS33
    , SUM(PIECES_SOLD34) PIECES_SOLD34
    , SUM(SCRAPS35) SCRAPS35
    , SUM(PIECES_UNACCOUNTED) * - 1 PIECES_UNACCOUNTED
       /*--== Head average  net_sales / chickenusage*/
    , CASE
          WHEN NVL( SUM(ChickenHeads33) / 8 , 0) = 0 THEN 0
          ELSE ROUND(SUM(net_sales2) / ( SUM(ChickenHeads33) / 8 ) , 2)
       END AS Head_average
       /*--=== Efficiency =   (ChickenUsage  - scrappedDiv8 - unaccountedDiv8) / ChickenUsage)  * 100*/
    , CASE
          WHEN NVL(SUM(ChickenHeads33) / 8 , 0) = 0 THEN 0
          ELSE ROUND((((SUM(ChickenHeads33) / 8 ) - ( SUM(scraps35) / 8 ) - (SUM(pieces_unaccounted) / 8 )) / (SUM(ChickenHeads33) / 8 )) * 100 , 2)
       END AS efficiency
    FROM period_data per
    WHERE week_DATE BETWEEN TRUNC(TO_DATE( '24-AUG-09' , 'DD-MON-YY') , 'IY') AND TRUNC(TO_DATE( '24-AUG-09' , 'DD-MON-YY') , 'IW') + 6 + 7 * 4
    GROUP BY  hot_dog_stand_id
    ,           ROLLUP (
                 CASE
                   WHEN  week_date >= TO_DATE( :start_date, 'DD-MON-YYYY')
                   AND   week_date <  TO_DATE( :start_date, 'DD-MON-YYYY') + 35
                   THEN  1 + FLOOR ( (week_date - TO_DATE( :start_date, 'DD-MON-YYYY'))
                                             / 7
                   ELSE  0
                 END          -- week_nbr
    ORDER BY  week_nbr
    ;Notice I simplified the computation of week_nbr.
    Some other people have asked questions about hot dog stands recently.
    I'm curious; is this from a course? If so, where? What is the textbook (if any)?
    Thanks.

Maybe you are looking for