Average no of farmers in each Mouza/Town.

I have a table name farmer data and it has attributes like farmer name, father name, pesticides used, town etc (these attributes would be required for query). also the data type of columns is var char. I have to write a query to calculate the average no
of farmers in each town. How can I write this query? I have tried this query but its not giving me correct answer.
select Farmer_Name, Count(distinct town)
from farmer_data
group by town
i have also tried another query, its giving output in correct format but the answer of farmers are very huge values. i want number of distinct farmers in every town, this query is counting all the farmers
select town, count (*)
from farmer_data
group by town

Farmer name                 town
Taimoor Shah                 Ch. 5-M
NUSRAT ali                      Ch. 77 M
kamal khan                     Hootwala
ABDUL KHALIQ               Gazipur
Anwar Kamal                   Hootwala
NUSRAT ali                       Ch. 77 M
now i want distinct number of farmers in every town.. i have 25 million records and i found distinct number of farmers with a query and its returning me 899. now issue is this query is returning me 899 against every town name. like in this query, output
should be
town name           farmers in each town
Ch. 5-M                 1
Ch. 77 M               2
Gazipur                 1
Hootwala               2
instead of giving this result, its giving me total number of farmers against each town, like in this scenario, output which i am getting  is
town name           farmers in each town
Ch. 5-M                 6
Ch. 77 M               6
Gazipur                 6
Hootwala               6
i hope my question is clear now..

Similar Messages

  • Return average of time interval in each hour for each day

    I am reading from a database and the data is stored like this
    Date................ Hour........Hour Interval..........Price
    2010/07/01.........1...................1.....................x
    2010/07/01.........1...................2.....................x
    2010/07/01.........1...................3.....................x
    2010/07/01.........1...................4.....................x
    2010/07/01.........1...................5.....................x
    2010/07/01.........1...................6.....................x
    2010/07/01.........1...................7.....................x
    2010/07/01.........1...................8.....................x
    2010/07/01.........1...................9.....................x
    2010/07/01.........1...................10...................x
    2010/07/01.........1...................11...................x
    2010/07/01.........1...................12...................x
    2010/07/01.........2...................1.....................x
    2010/07/01.........2...................2.....................x
    2010/07/01.........2...................3.....................x
    2010/07/01.........2...................4.....................x
    How would I write an sql statement to get the average for the price for each hour. The average should take the average of all the prices in the interval from 1 to 12
    Any suggestions
    Edited by: user13353366 on Jul 1, 2010 11:55 AM

    Hi,
    Welcome to the forum!
    Whenever you have a question, it helps if you post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data. No doubt you have a perfectly clear idea of what your data is, and what results you want, but other people are likely to make bad assumptions from just looking at a description of the problem. For example, are date and hour one colum or two? What role does hour_interval play in this problem?
    So, in addition to a description of the data and the probelm, post a specific example, like this for the data:
    CREATE TABLE     table_x
    (     dt          DATE
    ,     hour_interval     NUMBER (2)
    ,     price          NUMBER
    INSERT INTO table_x (dt, hour_interval, price) VALUES (TO_DATE ('2010/07/01 01', 'YYYY/MM/DD HH24'),   1,   1);
    INSERT INTO table_x (dt, hour_interval, price) VALUES (TO_DATE ('2010/07/01 01', 'YYYY/MM/DD HH24'),   2,   1.1);
    INSERT INTO table_x (dt, hour_interval, price) VALUES (TO_DATE ('2010/07/01 02', 'YYYY/MM/DD HH24'),   4,   9);
    INSERT INTO table_x (dt, hour_interval, price) VALUES (TO_DATE ('2010/07/01 02', 'YYYY/MM/DD HH24'),  13,   9.9);and like this for the results you want from that same data:
    HR             AVG_PRICE
    2010/07/01 01       1.05
    2010/07/01 02          9If those happens to be the results you would want from that data, then, as Lkbrwn said, AVG and GROUP BY can get them for you, like this:
    SELECT       TRUNC (dt, 'HH')     AS hr
    ,       AVG (price)          AS avg_price
    FROM       table_x
    WHERE       hour_interval     BETWEEN      1
                   AND     12
    GROUP BY  TRUNC (dt, 'HH')
    ORDER BY  hr
    ;

  • Need to display average percent of spend for each vendor in top ten

    Hi Friends,
                 I have to design a query where  I need to display top ten vendors and for that top ten vendors  need to sum the AMT and I have to calculate the average percentage of each vendor in top ten list from the total. Based and the specified range have to create exceptions.
    I am able to display top ten vendors. Now the problem is unable to calculate total of top ten vendors and average percentage of each vendor from total. like the below
         spend     Spend Ratio     Spend Percentage     
    vendor 4     121987     0.299181333     30%     80% is an A
    vendor 10     101103     0.247961917     55%     
    vendor 8     98723     0.242124806     79%     
    vendor 9     23456     0.05752742     85%     80-95% is a B
    vendor 5     12345     0.030276944     88%     
    vendor 6     10540     0.02585006     90%     
    vendor 7     9906     0.024295132     93%     
    vendor 3      9903     0.024287774     95%     95-100% is a C
    vendor 2     9899     0.024277964     98%     
    vendor 1     9874     0.02421665     100%     
    Total     407736               
    Please, suggest me to proceed further.
    Thank You.
    Manjula

    Hi manjula
    In order to get total for any key figure .... for that key figure at the query level in the  calculation tab there will be one box like calculate result as there u give sum or average accroding to ur purpose... then it will display the total or average accordingly....
    the key figure when used average for result shows average of all record conrtibutions but
    In order to display the  percentage of each vendor from total u can use
    Percentage Share of Result (%CT)
    %CT<Operand>
    Specifies how high the percentage share is in relation to the result. The result
    means the result of aggregation at the next level (interim result).
    %CT Incoming Orders specifies the share of incoming order values of each
    individual characteristic value (for example of each customer) in relation to
    the characteristic's result (for example, customer of a division).
    Regards
    vamsi

  • ICloud is not installing all my music tracks it only installs 16,600 of my 21589 the other 5,000 go to step three and take an average of 60/70 seconds each to upload, at that rate it would take 3days 15 hours to upload

    The last time I had a problem, about 6months ago, I found an eMail support service direct from Apple itunes and eMailed them. Within 24 hours they replied with a soloution, however that service seems to have been withdrawn. So can anyone help me with the following problem: I have 21,653 music tracks. Paid y money and tried to upload them to iTunes icloud. Step 1 & 2 went well, completed in just over an hour. However step 3 for uploading artwork and any remaining music tracks, of which there was over 4,000 for some reason, is taking on average 60/70 seconds to upload each track. At that rate it would take nearly 4 days to upload non stop. Can anyone tell me why this is happening?
    Thanking you in Anticipation of your help. Vince.

    Looking at the error message "The Network Adapter could not establish the connection" , It appears hostname and port may be incorrect. Review the targets.xml under E:\oracle\product\10.2.0\db_1\SAP_solman_SDB\emd and
    emoms.properties under E:\oracle\product\10.2.0\db_1\SAP_solman_SDB\config folder to make sure host ( sap_solman) and port (1527) are correct.
    As far as setting the environment variables goes, you can go to control panel -> system -> advanced -> environment variables and set the ORACLE_HOME and ORACLE_SID
    -Ramesh

  • Does Signal express save averaged data to LVM / Ascii / UFF file or all the individual runs?

    Hello,
            I am acquiring impact
    datausing NI sound and vibration and NI cRIO 9233. I am averaging the
    data over 10 hits and saving it to Ascii, LVM files. When I open the
    file in excel I see 12500 readings. The frequency resolution is 1.25Hz
    and range is 0 - 1562.5Hz that gives me 1250 divisions, which means its
    storing each of them separately. Why is it doing so and not storing the
    averaged data?
           Also could I possibly set a condition where
    the data is accepted by the software only if the hit is good and I want
    to accept it. May be like a condition where I could accept that data by
    clicking a push button?
    Attached is my acquisition template and also
    the data in ascii format. I collected data for 10 averages but the set
    is showing data for 11 averages or sets of 1250 each. Could someone
    please help me out.
     I need to get this going as soon as possible as I want to transfer data from Sound and Vibration assistant to another software.
    Thank you.
    Message Edited by StuMtu on 10-30-2008 11:39 AM
    Attachments:
    FRFdata_1.xls ‏1445 KB
    filtereddata_1.xls ‏3062 KB
    ImTe-10-29_run1_1 (DAQmx).seproj ‏787 KB

    Hey Stu,
    You had asked this question a while back. Did you have any problems implementing the solution I provided?  If so, please post in the original forum and we can take it from there.  Thanks!
    -John Sullivan
    Analog Engineer

  • Averaging n number of data per x time after stripping out zeros

    Hey all,
    Very new to LabView and dropped in the deep end. I have a DAQ outputting data at 10hz. I need to be able to average that dataset every second after filtering out values I do not want and the zero values also, before saving to file. Currently I am outputting the data, instructing it to zero the values outputting below 0.6 and above 1.8. From there I need to rempove the zeros, so to average the remaining values in each 1 second/10hz interval and output one value per second. 
    I have attached the file. 
    Thanks
    Attachments:
    Overflowing Froth Height.vi ‏110 KB

    So you want ot average only the values between 0.6 and 1.8?
    Well, we can go about this in 2 ways: build an array of data points to keep or delete the unwanted data points.  It is probably easiest to build an array of points to keep.  So here's what you should do.  Use a FOR loop and autoindex the waveform array.  Use the In Range and Coerce function to see if your current data point is within the range.  If it is add to the array.  The building of the array should be handled with a shift register.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    Build Array from Range.png ‏15 KB

  • Sort image files by average luminance and by average hue?

    Hi.  I would like to be able to sort images by average luminance and by average hue.  Is there anything in OS X that will let me determine the average luminance or average hue of an image, and save that datum to the image?
    Ultimately, I would like to use this within Aperture (my sole area of expertise {all my ASC points are from the Aperture forum}).  After I posted the question there, a regular suggested I post in this forum to find out what is possible:  specifically, are there any AppleScript hooks that might allow this?  (Sadly, I don't script, but it helps me know what can be done.)
    I know of one program which does this: CF/X's Photo Mosaic, which uses the averages to match an image to a tile in the "master image".  I don't know of any way to attach the Photo-Mosaic-generated averages to the files themselves.  I asked CF/X about this today.
    Thanks.

    Hello
    You may try the AppleScript script listed below. It is a simple wrapper of rubycocoa script which uses CIFilter to calculate average brightness and hue of each image (jpg|jpeg|png) in specified directory tree. It is a skeleton just to generate a TSV output of [brightness, hue, file] records sorted by brightness and then hue on desktop. I don't know how to embed these info into image metabata.
    Script is briefly tested under 10.6.8.
    Hope this may help somehow,
    H
    PS. If copied code has extra spaces in front of every line, which appears to be the case with some browsers including Firefox, please remove them before running the script.
    -- SCRIPT
    set d to (choose folder with prompt "Choose start folder")
    set args to d's POSIX path's quoted form
    do shell script "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -w <<'EOF' - " & args & " > ~/desktop/test_out.txt
    #     get average brightness and hue of image files (jpg|jpeg|png)
    #     * output record = B=brightness [TAB] H=hue [TAB] file [LF]
    #     * sorted by brightness and then hue
    require 'osx/cocoa'
    include OSX
    EXTS = %w[ jpg jpeg png ]    # target extensions
    module OSX
        class << CIContext
            def contextWithSize(w, h)
                br = NSBitmapImageRep.alloc.objc_send(
                    :initWithBitmapDataPlanes, nil,
                    :pixelsWide, w,
                    :pixelsHigh, h,
                    :bitsPerSample, 8,
                    :samplesPerPixel, 4,
                    :hasAlpha, true,
                    :isPlanar, false,
                    :colorSpaceName, NSCalibratedRGBColorSpace,
                    :bytesPerRow, 0,
                    :bitsPerPixel, 0)
                c = NSGraphicsContext.graphicsContextWithBitmapImageRep(br)
                CIContext.objc_send(:contextWithCGContext, c.graphicsPort , :options, {})
            end
        end
        class CIFilter
            def setParameters(dict)
                self.setValuesForKeysWithDictionary(dict)
            end
            def output
                self.valueForKey('outputImage')
            end
        end
        class << CIVector
            def vectorWithRect(r)
                self.vectorWithX_Y_Z_W(r.origin.x, r.origin.y, r.size.width, r.size.height)
            end
        end
    end
    # process ARGV and retrieve image files with given extensions under specfied directory
    raise ArgumentError, %Q[Usage: #{File.basename($0)} directory] unless ARGV.length == 1
    dir, = ARGV.map { |a| a == '/' ? a : a.chomp('/')}
    ff = %x[find -E \"#{dir}\" -type f -iregex '.*/.*\\.(#{EXTS.join('|')})$' -print0].split(/\\0/)
    # get CIContext and CIFilter
    cic = CIContext.contextWithSize(5000, 5000)  # let it be large enough
    cif = CIFilter.filterWithName('CIAreaAverage')
    cif.setDefaults
    # retrieve average brightness and hue of images
    hh = {}
    ff.each do |f|
        u = NSURL.fileURLWithPath(f)
        ci = CIImage.imageWithContentsOfURL(u)
        civ = CIVector.vectorWithRect(ci.extent)
        cif.setParameters({'inputImage' => ci, 'inputExtent' => civ})
        ciout = cif.output
        cgout = cic.objc_send(:createCGImage, ciout, :fromRect, ciout.extent)
        colr = NSBitmapImageRep.alloc.initWithCGImage(cgout).colorAtX_y(0, 0)
        hh[f] = { :b => colr.brightnessComponent, :h => colr.hueComponent}
    end
    # sort criteria
    brightness          = lambda { |k| hh[k][:b] }
    hue                 = lambda { |k| hh[k][:h] }
    brightness_and_hue  = lambda { |k| b, h = hh[k].values_at(:b, :h); b * 1e6 + h }
    # print sorted records
    hh.keys.sort_by(&brightness_and_hue).each do |k|
        b, h = hh[k].values_at(:b, :h)
        puts %Q[B=%f\\tH=%f\\t%s] %  [b, h, k]
    end
    EOF"
    -- END OF SCRIPT

  • Month average

    I would really like to make a query (I think that is the right word) to determine the average number of sales for each month (for example, Jan thru Dec). Not the average number of per month!
    I have a table as follows:
    CREATE TABLE sale
    id               VARCHAR2(32)     NOT NULL,
    item               VARCHAR2(32)     NOT NULL,
    saledate          DATE,
    PRIMARY KEY(id),
    Populated with data like:
    001 AAA 08-FEB-00
    002 ZZZ 14-MAR-01
    003 HHH 06-OCT-02
    004 DDD 30-MAR-03
    005 KKK 12-APR-03
    006 GGG 22-SEP-04
    007 BBB 15-MAR-04
    008 BBB 16-MAR-04
    009 SSS 17-MAR-04
    010 SSS 18-MAR-04
    011 BBB 19-MAR-04
    I did manage to create the below query which returns the average sales per month but this is NOT want I wish for:
    SELECT AVG(TOTAL)
    FROM (SELECT MONTH, COUNT(MONTH) as TOTAL
    FROM (SELECT TO_CHAR(saledate, 'MON') as MONTH from sale)
    GROUP BY MONTH);
    I would like an average output per month, example:
    JAN     0
    FEB     0
    MAR     2
    DEC     0
    I have no idea...
    Thanks...

    Okay, you want the average of the monthly sales. You can get that by doing this:
    SELECT to_char(x.month, 'MON') AS month, avg(mon_tot) AS avg
    FROM   ( SELECT trunc(month, 'MM') AS month, count(*) AS mon_tot
             FROM   sales
             GROUP  BY trunc(month, 'MM') x
    GROUP BY to_char(x.month, 'MON');Now your other problem is filling in the gaps for months where there are no sales. You will find Help Required for date display & mutating trigger to be helpful if you are using Oracle9i or higher, otherwise you will need to use Justin's variation.
    Cheers, APC

  • Advanced Datagrid with average and sum at bottom

    I have an xml file which has the following elements
    <element>
         <price>12</price>
         <type>b</type>
         <name>name1</name>
    </element>
    I'l like to have a tree which is first sorted by name, and then by type. Then it should sum up and average all the prices of each of those elements which have the same type and name.
    Any advice on how I can achieve this is highly appreciated.
    thanks

    Hi,
    try this.
    data w_cat type lvc_s_fcat,
    t_cat type lvc_t_fcat.
    w_cat-fieldname = 'CITYFROM'.
      w_cat-do_sum = 'X'
      APPEND w_cat TO t_cat.
      CLEAR w_cat.
    CALL METHOD r_alv_grid->set_table_for_first_display
        EXPORTING
       i_buffer_active               =
       i_bypassing_buffer            =
       i_consistency_check           =
          i_structure_name              = 'FS'
       is_variant                    =
       i_save                        =
       i_default                     = 'X'
          is_layout                     = w_lay
       is_print                      =
       it_special_groups             =
       it_toolbar_excluding          =
       it_hyperlink                  =
       it_alv_graphics               =
       it_except_qinfo               =
       ir_salv_adapter               =
        CHANGING
          it_outtab                     = itab
          it_fieldcatalog               = t_cat
    EXCEPTIONS
       invalid_parameter_combination = 1
       program_error                 = 2
       too_many_lines                = 3
       others                        = 4

  • What's the best program structure for multi-channel Averaged FFTs?

    I have been successfully using a 8-channel FFT analyzer using a separate Averaged FFT Spectrum (Mag-Phase) VI for each channel, but I now need to expand my channel count from 8 to 16. All channels are simultaneoulsy read in to a buffer to maintain phase relatioships. Do I need to have 16 copies of the Averaged FFT Spectrum VI in my diagram to maintain the averages of each channel or can I utilize one FFT VI somehow within a For Loop? If a For Loop can be used, how can the averaged spectrums be maintained for each of the 16 channels?

    You should be able to use a single FFT vi in a for loop. If your data is in a 2D array representation with each row representing a channel and you leave the indexing enabled you can pass your data array into the loop and it will strip off each row automatically. You could then pass each row of data to the FFT and pass the results out to the boundary of the for loop. This will then build an array containing the FFT results for each row (channel).
    Marc
    Marc

  • Making different signals for different color average of the pixcells

    Hello, everyone.
    I'll take image of paper money by webcam,
    and get the color average of the bills
    and fractionate the color average by wavelength range of each bills.
    and I want to making signal releasing time differently for different color average of the pixcells.(to fractionate the kind of bills)
    (I want different signal for different kind of bills) 
    my question is this:
    (1)How can I connect the webcam to the Labview?
    (2)How can I get the color average of paper money?
    (3)How can I make Labview program for releasing different signals which has different releasing time for each color average?

    Hi 박지성,
    you can use the IMAQ for USB Driver. See this link http://zone.ni.com/devzone/cda/epd/p/id/5030. You can also use the integrated windows dll to get your picture.
    Hope it helps.
    Mike

  • Averaging rows in an array

    I am trying to find the average of an array, but I need the average of the rows of each.  I don't know what function to use, because the only ones I can find take the average of the whole array.  I can't split up the array because there are a variable number of inputs that changes each time the array runs through a for loop where the user specifies the numer of times that the loop is run.

    There is a much faster possibility by using matrix multiplication. The function is called "A x B". See also attached image. The speed was faster by a factor of 13.
    Attachments:
    test.jpg ‏94 KB
    benchmark.vi ‏18 KB

  • Spatial Average

    Hi all.
    I'm very new to all this spatial business so bare with me.
    I need to calculate the average value of an attribute within a region.
    I have two tables. One that contains a cell_id, and the geometry column is a polygon that defines the bounding box of the cell. Each cell is approx 25km by 25km.
    In another table i have a reading for each cell for each day over a period of a few months.
    I need to be able to calculate the average over regions. For example the average for regions with a spatial resolution of 10 degrees.
    Does anyone know how i can do this?
    I realise i could build a query window and do a seperate query for each region. But that would be very very slow. Any other ideas?
    Thanks bec.

    I don't think that there is an out-of-the-box solution for your task but if I understandd you correctly the only thing you will have to do is to average the power associated with each 1/n octave band of all your microphones. In the S&V toolkit the band power is an output parameter of e. g. the SVT Third-octave Analysis.vi. The band powers for each channel are stored within arrays so you will simply have to average the corresponding array elements from each of your channels.
    Best regards,
    Jochen Klier
    National Instruments Germany

  • Creating a form with Running Averages

    Hi
    I am creating a Blood Glucose Monthly Form. It is organized by week with an average at the end of each week for the various times of day I test my sugar. Those results then contribute to averaging the weekly numbers for a monthly number. I have a similar form I am developing for Blood Pressure.
    My question is that since this a monthly form destined to be a template how do I get around the error messages that appear when there are blanks as I have not yet reached that day/ date. Can someone help with a formula that will work?
    Thank you
    Herbert

    Herbert,
    There is a function named "IFERROR" that will trap an error condition, prevent the alert and substitute a display/calculation that you choose. The syntax is: =IFERROR(original-expression, what-to-do-upon-error).
    Often it is sufficient to display a null string on error: IFERROR(original-expression, "").
    Jerry

  • I am measuring mV on 8 channels using 2 NI 9239's and want to find the mean of each channel

    I'm using 2 NI 9239's to capture the voltages at 8 point on a test fixture. The voltages are very small (a few mV). I want to take an average of 1k samples from each channel and use these to calculate the resistivity of the sample under test. 
    What is the easiest method to precisely measure 8 channels?

    Let's start from the beginning.  Do you know how to read 1k samples from 8 channels using a single DAQmx Task?  Once you have that, then use a FOR loop to do a mean on each channel's data.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

Maybe you are looking for

  • Which Table i will Get the Name of Receipt Recipient in FBCJ

    Hi Experts Which Table i will Get the Name of Receipt Recipient in FBCJ Transaction Code : FBCJ Technical name : Name of Receipt Recipient Field Name : BP_NAME But it is not stored in TCJ_POSITIONS table Regards Jagadish

  • Cani I upgrade to Version 9.4.2?

    I had to use my iPhoto library, which, is on an external hard drive on another computer. The verion of iPhoto on that computer is 9.4.2. Mine is 9.3. Is it possible for me to upgrade? All I can find online is Version 9.5.

  • Warranty Extensions: Postings on Sales Invoice

    Hi Gurus, Please help me set up this biz process. We need to track Non-inventory materials to help the sales departments identify those materials which create more revenue because of sold warranty extensions. Also this department must have future war

  • Runtime Errors         OBJECTS_OBJREF_NOT_ASSIGNED

    Runtime Errors         OBJECTS_OBJREF_NOT_ASSIGNED Except.                CX_SY_REF_IS_INITIAL Date and Time          24.09.2007 11:27:19 Short dump has not been completely stored (too big) Short text      Access via 'NULL' object reference not possi

  • Change in hardware key on new installation with same SID

    Dear Experts, Background: We installed SAP Netweaver 7.3 EHP1 on Microsoft Windows Server 2008 and applied SAP License on it. So there was a specific SID, Hardware key and Installation No to our installation. After few months our Server machine got c