SUM (case use this structure to get average values on the date range

I use:

Oracle SQL Developer (3.0.04) build hand - 04.34 Oracle Database 11 g Enterprise Edition 11.2.0.1.0 - 64 bit Production

How do we use the function sum with a structure of matter inside.

so I gave that looks like have an ID, date and value. I'm looking to get the day 7 medium for the date range of 04/01/2013 to 20/04/2013
with t as (
select 1 ID_Key,to_date('4/1/2013','mm-dd-yyyy') date_val, 10 Value_num from dual union all
select 1 ID_key,to_date('4/2/2013','mm-dd-yyyy'), 15 from dual union all
select 1 ID_key,to_date('4/3/2013','mm-dd-yyyy'), 20 from dual union all
select 1 ID_key,to_date('4/5/2013','mm-dd-yyyy'), 0 from dual union all
select 1 ID_key,to_date('4/8/2013','mm-dd-yyyy'), 12 from dual union all
select 1 ID_key,to_date('4/9/2013','mm-dd-yyyy'), 8 from dual union all
select 1 ID_key,to_date('4/10/2013','mm-dd-yyyy'), 6 from dual union all
select 1 ID_key,to_date('4/12/2013','mm-dd-yyyy'), 10 from dual union all
select 1 ID_key,to_date('4/13/2013','mm-dd-yyyy'), 0 from dual union all
select 1 ID_key,to_date('4/14/2013','mm-dd-yyyy'), 0 from dual union all
select 1 ID_key,to_date('4/15/2013','mm-dd-yyyy'), 10 from dual union all
select 1 ID_key,to_date('4/16/2013','mm-dd-yyyy'), 5 from dual union all
select 1 ID_key,to_date('4/17/2013','mm-dd-yyyy'), 2 from dual union all
select 1 ID_key,to_date('4/20/2013','mm-dd-yyyy'), 3 from dual union all
select 2 ID_key,to_date('4/3/2013','mm-dd-yyyy'), 12 from dual union all
select 2 ID_key,to_date('4/5/2013','mm-dd-yyyy'), 15 from dual union all
select 2 ID_key,to_date('4/6/2013','mm-dd-yyyy'), 5 from dual union all
select 2 ID_key,to_date('4/7/2013','mm-dd-yyyy'), 7 from dual union all
select 2 ID_key,to_date('4/9/2013','mm-dd-yyyy'), 10 from dual union all
select 2 ID_key,to_date('4/11/2013','mm-dd-yyyy'), 5 from dual union all
select 2 ID_key,to_date('4/12/2013','mm-dd-yyyy'), 0 from dual union all
select 2 ID_key,to_date('4/13/2013','mm-dd-yyyy'), 0 from dual union all
select 2 ID_key,to_date('4/15/2013','mm-dd-yyyy'), 6 from dual union all
select 2 ID_key,to_date('4/16/2013','mm-dd-yyyy'), 8 from dual union all
select 2 ID_key,to_date('4/17/2013','mm-dd-yyyy'), 0 from dual union all
select 2 ID_key,to_date('4/18/2013','mm-dd-yyyy'), 10 from dual union all
select 2 ID_key,to_date('4/19/2013','mm-dd-yyyy'), 5 from dual
)
* Please let me know if the table does not load.

I would get the average of 7 days, as long as there is date for the rank of enough previous dates, is it not, then it returns a null value.

the results should look like this
ID_Key      date_val     Value_num     7Day_Avg     7Day_Avg2
1     4/1/2013     10          null          null
1     4/2/2013     15          null          null
1     4/3/2013     20          null          null
1     4/5/2013     0          null          null
1     4/8/2013     12          6.71          11.75
1     4/9/2013     8          5.71          10.00
1     4/10/2013     6          3.71          6.50
1     4/12/2013     10          5.14          9.00
1     4/13/2013     0          5.14          7.20
1     4/14/2013     0          5.14          6.00
1     4/15/2013     10          4.86          5.67
1     4/16/2013     5          4.42          5.17
1     4/17/2013     2          3.85          4.50
1     4/20/2013     3          2.86          4.00
2     4/3/2013     12          null          null
2     4/5/2013     15          null          null
2     4/6/2013     5          null          null
2     4/7/2013     7          5.57          9.75
2     4/9/2013     10          7.00          9.80
2     4/11/2013     5          6.00          8.40
2     4/12/2013     0          3.86          5.40
2     4/13/2013     0          3.14          4.40
2     4/15/2013     6          3.00          4.20
2     4/16/2013     8          2.71          3.80
2     4/17/2013     0          2.71          3.17
2     4/18/2013     10          3.43          4.00
2     4/19/2013     5          4.14          4.83
As you can see, there are gaps in the dates, the value is then processed by zeros for the 7Day_Avg and then ignored for the 7Day_Avg2 (not counted in the number of days on average do to no valu_num line)
I tried something like this at first, but becomes "missing keyword" error
select
t.*/,
sum(
      case 
        when date_val between :day2 - 6 and :day2
        then value_num between date_val - 6 and date_val
        else null
        end
        )
        as 7Day_avg

form t
Should I have the structure outside the sum function?

Any thoughts?

Published by: 1004407 on June 7, 2013 11:06

Hello

If you want to calculate the average of the last 7 days, including the current day, then then RANGE should be 6 PRIOR, not 7.

Try this:

WITH got_min_date_val AS

(

SELECT id_key, date_val, value_num

MIN (date_val) compared to (AS min_date_val)

T

WHERE the date_val BETWEEN TO_DATE (April 1, 2013 ', "dd-mm-yyyy")

AND TO_DATE (April 20, 2013 ', "dd-mm-yyyy")

)

SELECT id_key, date_val, value_num

CASE

WHEN date_val > = min_date_val + 6

THEN SUM (value_num) OVER (PARTITION BY id_key

ORDER BY date_val

PRIOR TO TIER 6

)

/ 7

END AS avg_7_day

CASE

WHEN date_val > = min_date_val + 6

THEN AVG (value_num) OVER (PARTITION BY id_key

ORDER BY date_val

PRIOR TO TIER 6

)

END AS avg_7_day_2

OF got_min_date_val

ORDER BY id_key

date_val

;

Output:

ID_KEY DATE_VAL VALUE_NUM AVG_7_DAY AVG_7_DAY_2

---------- --------- ---------- ---------- ------------

1 1 APRIL 13 10

1 2 APRIL 13 15

1 APRIL 3, 13 20

1 5 APRIL 13 0

1 APRIL 8, 13 12 6.71 11.75

1 APRIL 9, 13 8 5.71 10.00

1 APRIL 10 13 6 3.71 6.50

1 12 APRIL 13 10 5.14 9,00

1 13 APRIL 13 0 5,14 7.20

1 14 APRIL 13 0 5,14 6.00

1 15 APRIL 13 10 4.86 5.67

1 16 APRIL 13 5 4.43 5.17

1 APRIL 17, 13 2 3.86 4.50

1 APRIL 20, 13 3 2.86 4.00

2 APRIL 3, 13 12

2 5 APRIL 13 15

2 6 APRIL 13 5

2 7 APRIL 13 7 5.57 9.75

2 9 APRIL 13 10 7,00 9.80

2 11 APRIL 13 5 6.00 8.40

2 12 APRIL 13 0 3.86 5.40

2 13 APRIL 13 0 3.14 4.40

2 15 APRIL 13 6 3.00 4.20

2 16 APRIL 13 8 2.71 3.80

2 17 APRIL 13 0 2.71 3.17

2 18 APRIL 13 10 3.43 4.00

2 APRIL 19, 13 5 4.14 4,83

Post edited by: FrankKulash

Sorry; I wanted to respond to OP, not Greg

Tags: Database

Similar Questions

  • Impossible to get Min, Max and median of the values in the date range values

    Hello

    I had a requirement as to show the data of each charge group of wise men as '< 100' ' 100-199 "" 200-299 "" 300-399 "400-499, 500-599 600-699 700-799 800-899 900-999 > = 1000 '"»

    With the query be able to get the count between the beach and the total below. But impossible to get the Min and Max values for this range. For example if the County < 100 is 3 then in these 3, the lowest value is need to display in the min. Idem for Max column also.

    In the light of the median value on these values.

    Thanks in advance.



    Requirement is as below:
    State < 100 100-199, 200-299 300-399 400-499, 500-599 600-699 700-799 800-899 900-999 > = 1000 Min Total median Max
    AK 1 2 0 4 1 4 4 35 35 4 1 $25 $85 850 $1,200
    AL 0 0 2 27 10 17 35 2 2 35 0 $103 100-$1 500 750


    * "QUERY ' * '"

    WITH t AS
    (SELECT 'AL' State, 12 DUAL FROM VALUE
    UNION ALL
    SELECT 'AL' State, 67 FROM DUAL VALUE
    UNION ALL
    SELECT 'AL' State, 23 FROM DUAL VALUE
    UNION ALL
    SELECT 'AL' State, 12 DUAL FROM VALUE
    UNION ALL
    SELECT 'AL' State, 12 DUAL FROM VALUE
    UNION ALL
    SELECT 'AL' State, 78 FROM DUAL VALUE
    UNION ALL
    SELECT 'AL' State, 34 FROM DUAL VALUE
    UNION ALL
    SELECT 'AL' State, 4 DUAL FROM VALUE
    UNION ALL
    SELECT 'AL' State, 12 DUAL FROM VALUE
    UNION ALL
    SELECT 'AL' State, 15 VALUE FROM DUAL
    UNION ALL
    SELECT "AZ" State, FROM DUAL VALUE 6
    UNION ALL
    SELECT "AZ" State, 123 FROM DUAL VALUE
    UNION ALL
    SELECT "AZ" State, 123 FROM DUAL VALUE
    UNION ALL
    SELECT 'MY' State, 23 FROM DUAL VALUE
    UNION ALL
    SELECT 'MY' State, 120 FROM DUAL VALUE
    UNION ALL
    SELECT 'MY' State, 456 FROM DUAL VALUE
    UNION ALL
    SELECT 'MY' State, 11 FROM DUAL VALUE
    UNION ALL
    SELECT 'MY' State, 24 FROM DUAL VALUE
    UNION ALL
    SELECT 'MY' State, 34 FROM DUAL VALUE
    UNION ALL
    SELECT 'MY' State, 87 DUAL FROM VALUE
    UNION ALL
    SELECT 'MY' State, 23 FROM DUAL VALUE
    UNION ALL
    SELECT 'MY' State, 234 DUAL FROM VALUE
    UNION ALL
    SELECT 'MY' State, 789 FROM DUAL VALUE
    UNION ALL
    SELECT "HD" State, VALUE FROM DUAL 54321).
    -End of test data
    AS T1
    (SELECT State,
    NVL (COUNT (DECODE (VALUE, 0, 0)), 0) '< 100 ',.
    NVL (COUNT (DECODE (VALUE, 1, 1)), 0) '100-199.
    NVL (COUNT (DECODE (VALUE, 2, 2)), 0) '200-299.
    NVL (COUNT (DECODE (VALUE, 3, 3)), 0) '300-399.
    NVL (COUNT (DECODE (VALUE, 4, 4)), 0) '400-499.
    NVL (COUNT (DECODE (VALUE, 5, 5)), 0) '500-599,'
    NVL (COUNT (DECODE (VALUE, 6, 6)), 0) '600-699.
    NVL (COUNT (DECODE (VALUE, 7, 7)), 0) '700-799.
    NVL (COUNT (DECODE (VALUE, 8, 8)), 0) '800-899.
    NVL (COUNT (DECODE (VALUE, 9, 9)), 0) '900-999. "
    NVL (COUNT (DECODE (VALUE, 10, 10)), 0) ' > = 1000.
    (SELECT STATE,
    CASE
    WHAT VALUE < 100 THEN 0
    WHAT A VALUE BETWEEN 100 AND 199 THEN 1
    WHAT VALUE BETWEEN 200 AND 299, THEN 2
    WHAT VALUE BETWEEN 300 AND 399 THEN 3
    WHAT VALUE BETWEEN 400 AND 499 THEN 4
    WHAT VALUE BETWEEN 500 AND 599 5 THEN
    WHAT VALUE BETWEEN 600 AND 699 6 THEN
    WHAT VALUE BETWEEN 700 AND 799 THEN 7
    WHAT VALUE BETWEEN 800 AND 899 8 THEN
    WHAT VALUE FROM 900 TO 999 9 THEN
    WHAT VALUE > = 10 THEN 1000
    END
    VALUE
    T)
    GROUP BY State)
    SELECTION STATE,
    "< 100."
    "100-199.
    "200 299",
    "300-399.
    "400-499.
    '500-599,'
    "600-699.
    "700-799.
    "800-899.
    "900-999."
    "> = 1000."
    '< 100 '.
    + "100-199.
    + "200-299.
    + '300-399.
    + '400-499.
    + "500-599.
    + '600-699.
    + "700-799.
    + "800-899.
    + '900-999 ".
    + ' > = 1000.
    in total,.
    less ("< 100",)
    "100-199.
    "200 299",
    "300-399.
    "400-499.
    '500-599,'
    "600-699.
    "700-799.
    "800-899.
    "900-999."
    ("> = 1000 ') min_val,.
    largest ("< 100",)
    "100-199.
    "200 299",
    "300-399.
    "400-499.
    '500-599,'
    "600-699.
    "700-799.
    "800-899.
    "900-999."
    ("> = 1000 ') max_val
    FROM t1
    /

    Why not keep it simple?

    WITH t AS
    (SELECT 'AL' state, 12 VALUE FROM DUAL
    UNION ALL
    SELECT 'AL' state, 67 VALUE FROM DUAL
    UNION ALL
    SELECT 'AL' state, 23 VALUE FROM DUAL
    UNION ALL
    SELECT 'AL' state, 12 VALUE FROM DUAL
    UNION ALL
    SELECT 'AL' state, 12 VALUE FROM DUAL
    UNION ALL
    SELECT 'AL' state, 78 VALUE FROM DUAL
    UNION ALL
    SELECT 'AL' state, 34 VALUE FROM DUAL
    UNION ALL
    SELECT 'AL' state, 4 VALUE FROM DUAL
    UNION ALL
    SELECT 'AL' state, 12 VALUE FROM DUAL
    UNION ALL
    SELECT 'AL' state, 15 VALUE FROM DUAL
    UNION ALL
    SELECT 'AZ' state, 6 VALUE FROM DUAL
    UNION ALL
    SELECT 'AZ' state, 123 VALUE FROM DUAL
    UNION ALL
    SELECT 'AZ' state, 123 VALUE FROM DUAL
    UNION ALL
    SELECT 'MA' state, 23 VALUE FROM DUAL
    UNION ALL
    SELECT 'MA' state, 120 VALUE FROM DUAL
    UNION ALL
    SELECT 'MA' state, 456 VALUE FROM DUAL
    UNION ALL
    SELECT 'MA' state, 11 VALUE FROM DUAL
    UNION ALL
    SELECT 'MA' state, 24 VALUE FROM DUAL
    UNION ALL
    SELECT 'MA' state, 34 VALUE FROM DUAL
    UNION ALL
    SELECT 'MA' state, 87 VALUE FROM DUAL
    UNION ALL
    SELECT 'MA' state, 23 VALUE FROM DUAL
    UNION ALL
    SELECT 'MA' state, 234 VALUE FROM DUAL
    UNION ALL
    SELECT 'MA' state, 789 VALUE FROM DUAL
    UNION ALL
    SELECT 'MH' state, 54321 VALUE FROM DUAL)
    SELECT state
         , NVL( COUNT( case when VALUE < 100 then 0 end ), 0 ) "<100"
         , NVL( COUNT( case when VALUE between 100 and 199 then 0 end ), 0 ) "100-199"
         , NVL( COUNT( case when VALUE between 200 and 299 then 0 end ), 0 ) "200-299"
         , NVL( COUNT( case when VALUE between 300 and 399 then 0 end ), 0 ) "300-399"
         , NVL( COUNT( case when VALUE between 400 and 499 then 0 end ), 0 ) "400-499"
         , NVL( COUNT( case when VALUE between 500 and 599 then 0 end ), 0 ) "500-599"
         , NVL( COUNT( case when VALUE between 600 and 699 then 0 end ), 0 ) "600-699"
         , NVL( COUNT( case when VALUE between 700 and 799 then 0 end ), 0 ) "700-799"
         , NVL( COUNT( case when VALUE between 800 and 899 then 0 end ), 0 ) "800-899"
         , NVL( COUNT( case when VALUE between 900 and 999 then 0 end ), 0 ) "900-999"
         , NVL( COUNT( case when VALUE >= 1000 then 0 end ), 0 ) ">=100"
         , count( value ) "total"
         , min( VALUE ) "min"
         , max( VALUE ) "max"
         , avg( VALUE ) "avg"
         , median( value ) "median"
    from t
    group by state
    
  • I lost my Muse files, when my computer broke down. went to my domain, all of my info Web sites host goDaddy. in a file zip (websitebackup3.zip) how to use this Info. to get my Web site up?

    My name is KennyD

    I lost my Muse files, when my computer broke down. went to my domain, all of my info Web sites host goDaddy. in a file zip (websitebackup3.zip) how to use this Info. to get my Web site up?

    You can not. You need the .muse file.

    Always a good idea to keep backups.

  • MSN - CRASH - TECH MSN TOLD - not able to use msn and I get a msg in the event viewer that the error is NTDLL. DLL

    MSN TECH SAID TELL WINDOWS CE PROBLEM I am STICK - not able to use msn and I get a msg in the event viewer that the error is NTDLL. DLL and talked with msn. Called MSN windows Dept. -How can I correct this situation?

    Hello

    Did you change your computer?

    Method 1:

    I suggest you perform the clean boot and check.

    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7

    http://support.Microsoft.com/kb/929135

    Note: After a repair, be sure to set the computer to start as usual as mentioned in step 7 in the above article.

    Method 2:

    I also suggest you to follow the link and check.

    How to use the System File Checker tool to fix the system files missing or corrupted on Windows Vista or Windows 7

    http://support.Microsoft.com/kb/929833

  • Error "You need a WIA driver to use this device" when you try to open the Canon DR5010C

    Original title: get a Windows Image Acquisition driver to work with a Canon DR5010C attached by usb port

    I have already downloaded drivers TWAIN & SISI and still get the error message "You need a WIA driver to use this device" when I try to open the Canon DR5010C of the printers & damage.  I am looking for a driver interface solution.

    Hello JRWORK,

    You will need to contact Canon because they provide the drivers for your Canon DR5010C device.
    http://www.USA.Canon.com/Cusa/Office/products/hardware/scanners/high_speed_document_scanners/imageformula_dr_5010c_color_production_scanner#DriversAndSoftware

    I hope this helps.

    Thank you

    Marilyn
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think

  • For psc 1315: before you can use this feature, OneNote 2010 must start for the first time.

    I installed the downloaded software (Windows 7) for my old psc 1315 (all-in-in-one). It printed the page sample after installation, but when I want to print what this or else it gives me the following message is displayed:

    "Before you can use this feature, OneNote 2010 must start for the first time."

    Restart the PC does not solve the problem either. How can I get the printer to work?

    Hello pietpompies7

    See the following Microsoft Office Blog article. It deals with OneNote arise while you try to print.

    Microsoft OneNote is misuse of your print jobs?

  • Why can't I configure the POP/IMAP mails for my Muse site in Business Catalyst? I don't have the option "use this service for e-mail as hosting the Web site" under Advanced options

    Why can't I configure the POP/IMAP mails for my Muse site in Business Catalyst? I don't have the option "use this service for e-mail as hosting the Web site" under Advanced options.

    Is this due to my hosting Plan? Appreciate the answers.

    Your site is a CCM that is located on a WebBasics plan (this plan does not e-mail hosted on Business Catalyst).

    If you want to create the email addresses on this site, you will need to configure your mail elsewhere server and configure the MX records on your site to point to the external mail server.

    If you want to use the hosted Business catalyst e-mail services, you should use a WebBasics + or superior siteplan. To upgrade your free CCM site, access administration area of your site-> Site Management-> upgrade now-> choose the desired site plan and billing frequency-> Add personal and credit card details-> Submit.

    Please see this article on setting up email on your site of BC accounts: http://docs.businesscatalyst.com/user-manual#! / settings/mail electronic-users of the site -

    For the establishment of the records point to the external mail server, see http://docs.businesscatalyst.com/user-manual#! / settings/email-users/creation-boxes of reception-for-your-users of the site

    Kind regards

    Laurant

  • calculation of the average value of the sorted data and polar route drawing

    Hello

    I did a VI that calculates the average value of the wind rotor/speed-ratio in the sections of 30 degrees (wind direction). He also called the polar plot of calculated data. Everything works, but I would like to make more detailed calculations and drawings, by increasing the resolution to 1 degree, or...

    Problem is VI, I did, is not easy on a large scale. At the moment, I have 12 parallel structures of switch-box to calculate the average value and build the array function to collect data calculated for Polar plot to draw the image in real time. I know it's probably the worst way to do it, but since I have done a few things with LV, it was the only way I managed to do what I wanted.

    Now, if I continue in same way to reach my goal, I have to create 360 Parallels switch-case structures... that are crazy.

    Something like the calculation of the average of the table or matrix (zero/empty values should not be calculated on average) inside the loop or similar way would probably be the best solution.

    So, polar plot drawing is not a problem, but creating a reasonalbe average metering system is. Any ideas?

    I would also like to rotare northward to the top (0 deg), and degrees of increase in a clockwise direction on polar ground dial plate (as on the compass).

    VI on the attachment. (simplified version of the complete system)

    I have signals:

    -Wind speed

    -wind direction

    -Rotor speed

    I want to:

    -calculate the average value of the speed of the wind / rotor - ratio in sections (5 degrees, 1 degree)

    -Draw a polar path of the wind rotor/speed-ratio of averages in propotion of wind direction

    I'm using LabView 2009

    Thank you very much.

    It is closer to what you're looking for?

  • Get number of records in the date range - IDE: PLSQL Developer

    I want to count the number of records of members who register within a date range specified, based on effective and expiration dates and their "elg_code". I posted the SQL code for some examples of data. What I would like to see returned is in three columns of the counties where the eff_date date_exp members fall within the date range specified by the SQL and have an Elg_code of ' ' (space).

    So what I would like is all members with elg_code ' ' where he eff_dt and exp_dt range is April 2012, 2012 MAY & JUN 2012. Thus, according to data from the sample I posted, Mark, where his elg_code record is ' ', his eff_dt is 01/01/2011 and April 2012 (30/04/2012) is his exp_dt. Range of the brand statement may 2012, but not MAY or JUNE of 2012. Marty would tally for the APR and MAY because his eff_dt is before MAY 2012 and his exp to MAY 2012. etc...

    According to the data below, the results should resemble:

    APR MAY JUN
    4-3-2

    APR should have FRANK, MARK, MARTY, MARY.
    MAY should have FRANK, MARTY, MARY
    JUN should have FRANK and MARIE

    NOAM and JOHN should not appear as his records with elg_code ' ' have no documents eff_dt and exp_dt which are April-June 2012.

    So what I tried without success as it appears that I have a kind of Cartesian question (?), is:

    Select count (m1.mbr_name) APR,
    Count (m2.mbr_name) MAY,
    Count (m3.mbr_name) JUN
    mbr2 M1,
    mbr2 m2,
    mbr2 m3
    "where m1.eff_dt < ' 01 - may - 2012"
    "and m1.exp_dt > ' 01-Apr-2012.
    and m1.elg_code = ' '
    "and m2.eff_dt < 1 June 2012"
    "and m2.exp_dt > ' 01 - may - 2012"
    and m2.elg_code = ' '
    "and m3.eff_dt < 1 July 2012"
    "and m3.exp_dt > 1 June 2012"
    and m3.elg_code = ' '


    Here's the DML

    Thanks for any help!


    create table mbr2 (mbr_name varchar (10), varchar (1) grpid eff_dt date, date of exp_dt elg_code varchar (1))
    Commit

    insert into mbr2 values ('BRAND', 'A', to_date (January 1, 2011 ',' DD-MM-YYYY '), to_date (April 30, 2012 ',' DD-MM-YYYY '), ' ')
    insert into mbr2 values ('BRAND', 'A', to_date (May 1, 2012 ',' DD-MM-YYYY '), to_date (31 December 2013 ',' DD-MM-YYYY '), 'C')

    insert into mbr2 values ('MARTY', 'A', to_date (January 1, 2011 ',' DD-MM-YYYY '), to_date (May 31, 2012 ',' DD-MM-YYYY '), ' ')
    insert into mbr2 values ('MARTY', 'A', to_date (June 1, 2012 ',' DD-MM-YYYY '), to_date (31 December 2013 ',' DD-MM-YYYY '), 'C')

    insert into mbr2 values ('FRANK', 'B', to_date (January 1, 2011 ',' DD-MM-YYYY '), to_date (June 30, 2012 ',' DD-MM-YYYY '), ' ')
    insert into mbr2 values ('FRANK', 'B', to_date (July 1, 2012 ',' DD-MM-YYYY '), to_date (31 December 2013 ',' DD-MM-YYYY ""), 'C')

    insert into mbr2 values ('MARY', 'B', to_date (January 1, 2011 ',' DD-MM-YYYY '), to_date (June 30, 2012 ',' DD-MM-YYYY '), ' ')
    insert into mbr2 values ('MARY', 'B', to_date (July 1, 2012 ',' DD-MM-YYYY '), to_date (31 December 2013 ',' DD-MM-YYYY ""), 'C')

    insert into mbr2 values ('JOHN', 'C', to_date (January 1, 2011 ',' DD-MM-YYYY '), to_date (July 1, 2011 ',' DD-MM-YYYY '), ' ')
    insert into mbr2 values ('JOHN', 'C', to_date (July 1, 2011 ',' DD-MM-YYYY '), to_date (1 January 2012 ',' DD-MM-YYYY ""), 'C')

    insert into mbr2 values ("NOAM" 'd', to_date (July 1, 2012 ',' DD-MM-YYYY '), to_date (31 December 2013 ',' DD-MM-YYYY '), ' ' ")

    Commit

    This gives you a report for the current month and the two front. Column header must be adjusted ;-)

    select
      count(
      case
      when
        eff_dt < add_months(trunc(sysdate,'MM'), -1)
        and
        exp_dt >= add_months(trunc(sysdate,'MM'), -2)
      then 1
      end) April
    , count(
      case
      when
        eff_dt < add_months(trunc(sysdate,'MM'), 0)
        and
        exp_dt >= add_months(trunc(sysdate,'MM'), -1)
      then 1
      end) May
    , count(
      case
      when
        eff_dt < add_months(trunc(sysdate,'MM'), 1)
        and
        exp_dt >= add_months(trunc(sysdate,'MM'), 0)
      then 1
      end) June
    from mbr2
    where
    elg_code = ' '
    and
    eff_dt < add_months(trunc(sysdate,'MM'), 1)
    and
    exp_dt >= add_months(trunc(sysdate,'MM'), -2)
    
    APRIL     MAY     JUNE
    4     3     2
    
  • \\N-PC is not accessible. You might not have permission to use this network resource while trying to access the network computer

    Title: Cannot access computers on my network?

    For some reason any my computer won't let me access any computer on my network.

    When I try to open any computer, including mine, since the tab "network" on the left he gives an error message saying "\\N-PC is not accessible. You might not have permission to use this network resource. Contact the administrator of this server to find out if you have access permissions. The specified network provider name is invalid.
    I ran the corner store to home group and network troubleshooting & two is out clearly said there are no problem.
    Anyone know how to fix this?

    Hello

    -What are the versions of the operating system installed on the conencted to computers in the network?

    -Did you do changes on the computer before this problem?

    Step 1: I suggest you to choose a network location, and then try to access the computer and check if it helps.

    Choose a network location

    http://Windows.Microsoft.com/en-us/Windows7/choosing-a-network-location

    Step 2: I also suggest you to check the network troubleshooter event logs to solve network problems and to check if it helps.

    Use Network Troubleshooter event logs to solve network problems

    http://Windows.Microsoft.com/en-us/Windows7/use-Network-Troubleshooter-event-logs-to-solve-network-problems

    Step 3: If the problem persists, I suggest you to follow the steps from the link and check if the problem persists.

    Why can't I connect to other computers?

    http://Windows.Microsoft.com/en-us/Windows7/why-can-t-I-connect-to-other-computers

    For reference:

    Networking of computers running different versions of Windows

    http://Windows.Microsoft.com/en-us/Windows7/networking-home-computers-running-different-versions-of-Windows

    Step 4: Disable the Antivirus

    I suggest to disable the Antivirus/Firewall temporarily, then check the issue.
    http://Windows.Microsoft.com/en-us/Windows7/disable-antivirus-software http://Windows.Microsoft.com/en-us/Windows7/turn-Windows-Firewall-on-or-off

    Note: Antivirus software can help protect your computer against viruses and other security threats. In most cases, you should not disable your antivirus software. If you need to disable temporarily to install other software, you must reactivate as soon as you are finished. If you are connected to the Internet or a network, while your antivirus software is disabled, your computer is vulnerable to attacks.
    Note: Please make sure that you enable the antivirus software after the test to keep your computer protected.

    Note: Turning off Windows Firewall may make your computer (and your network, if you have one) more vulnerable to damage caused by worms or hackers.

    Hope this information helps.

  • How to use a parameter query to select and display the data in the table of the façade

    Hiiiiii

    I am using Access 2007 database
    I want to select the specific data in the database using control of the chain as 'select product, size, weight of ProductInfo where barcode (chain control) =?'  and also display the same table of façade.

    I use the connected database toolkit.
    I saw the example of the parameterized insert, but it did not help to use parameterized select query, as well as to display data of parameterized select query.

    I looked for example on parameterized select query, but I don't have any.
    So pls guide me how to do this. I would like to know the other method (if any) that the use of parameter query to perform the same thing.
    If possble pls share a vi reference.
    Thank you!!!

    HII szewczak
    Thanks for the reply
    but I did not getsolution in one of your shared links
    My problem is solved. There is no need to use the parameter query to select control values
    In my case I want to display data from database where bar code is even entered by the user
    I use the data function DB TOOL CHOOSE and create the condition of chain based on concatenation of strings

  • VI data on average compared to the data from the Excel file on average .lvm

    I am trying to build a .VI to measure voltages on a channel of a transducer of pressure for a period of 3 minutes.  I would like the .VI to write all the samples of blood to a file .lvm with another .lvm file that comes from the average voltage over the period of 3 minutes.  I built a .VI making everything above so I think that... The problem I'm running into is when I opened the file .lvm of all samples of blood in MS Excel and take the average of them using the built-in Excel function (= AVERAGE(B23:B5022) for example) averaged and compare it to the .lvm file, which has just 3 minute average .VI voltage, they do not correspond to the top.

    This makes me wonder if I use VI with an average of function correctly or if maybe VI averages data different voltage than what is written in the .lvm file.

    Does anyone know why the two averages are different and how I can match.

    I have attached a picture of my functional schema with the file .VI for clarity.

    The Type of dynamic data of LabVIEW you use is a special data type that can take many forms.  It therefore requires the use "Of DDT" and "DDT" for the conbert to and from other data types.  These special conversion functions can be configured by double-clicking them and specifying the format you are converting from.  You can find the functions on the pallet handling Express-Signal.

    I've attached a screenshot of the modification of the code using the "DDT" and the average is very good.

    Please mark this as accepted such solution and/or give Kudos if it works for you.  We appreciate the sides for our answers.

    Thank you

    Dan

  • How to get the day as a numeric value without the date in shape?

    Hello
    to reduce the costs of a sql statement, I need to get the day of a date under the number (to compare to a numerical value) value without formatting. Each formatting causes a complete table of the table scan and the date field. Is there a function for this problem?

    Version of Oracle's 11g.

    Thank you Carsten

    You can use EXTRACT...

    SQL> select extract(day from sysdate) from dual;
    
    EXTRACT(DAYFROMSYSDATE)
    -----------------------
                          7
    
    SQL>
    
  • How can I use a context menu to change values in the numbers?

    I would use a context menu to view different values depending on whether you choose.

    example: projects

    sheet 1: projects, broken down by supplies, each of the deliveries was the price. I currently have this game to show me all the neede resources to complete everything, I want to implement in order to choose a pop up of a building of character, etc. and have it show me how it is necessary for this.

    HI Black Jack,

    I'm sure that many young people can do what you ask, but I do not understand your table - what data you want to move where and the place where.

    What would be in the context menu, where the popup would be and where the data would be displayed.

    Quinn

  • Get the date range min/max for consecutive events.

    Hi all...

    I am fairly new to the programming of the DB and is working on some examples I picked up a few places. The database version is 10g R2.

    I would like to configure the data here and I can explain my requirement.

    create table table_1
    (product_id varchar2(25),
    region_id  number,
    event_id number
    event_date date,
    event_status number(1))
    /
    
    
    

    Now the data because it is->

    insert into table_1 values ('Prod-1',10, null, to_date('01-feb-2014','dd-mon-yyyy'),null)
    /
    insert into table_1 values('Prod-1',10, 1001, to_date('10-mar-2014','dd-mon-yyyy'), 1)
    /
    insert into table_1 values('Prod-1',10, 1001, to_date('20-mar-2014','dd-mon-yyyy'), 3)
    /
    insert into table_1 values('Prod-1',10,1002, to_date('01-apr-2014','dd-mon-yyyy'), 1)
    /
    insert into table_1 values('Prod-1',10, 1002, to_date('10-apr-2014','dd-mon-yyyy'), 3)
    /
    commit
    /
    
    
    
    

    If the table now contains the following data

    select * from table_1; 
    
    
    

    PRODUCT_ID REGION_ID EVENT ID EVENT_DAT EVENT_STATUS

    ------------------------- ---------- -------- --------- ------------

    Prod-1 10 1 February 14

    Prod-1 10 1001 10 March 14 1

    Prod-1 10 1001 20 March 14 3

    Prod-1 10 1002 1 April 14 1

    Prod-1 10 1002 April 10, 14 3

    Now, the condition is as follows:

    Above is the dates start and end for the tests on a product in a given region. The event_status column indicates the dates of beginning and end. Event_status = 1, for the date of beginning and the event_status = 3 of the end date.

    A new event is now coming from March 21 and ending on March 31.

    The power required is a product identifier / region; If there are events that are ending and then count the days, for example, 1001 to end on March 20, but now the new event begins on 21 March... and the new event ends on 31 March and event 1002 begins 01 - Apr... and so on.

    The output required for this is as follows:

    PRODUCT_ID REGION_ID EVENT_MIN_DATE EVENT_MAX_DATE

    ------------------------- ---------- -------------- --------------

    Prod-1 10 10 14 March 10 April 14

    The output should give a product identifier / region, when events are immediately after the other, out the min date of beginning and end of max for all these manifestations of "back to back".

    Now I wrote the code for this, but it goes into a purely 'loop' for application in PLSQL... But my head tells me that if the results are correct. the PLSQL implementation is not the most efficient and effective way.

    Can someone help me to form the query? I tried to use functions analytical min/max but it gives me the start and end dates back even if my events are not "back to back" or previous/succeed each other... so my query result is not quite correct.

    Am reading on the TYPE clause but would be grateful if someone could help me with this query... or any other form better to implement this event so PLSQL can be used. The database version is 10g R2.

    Thank you

    K

    PS - The number of such events back to back is limited to 4 and the events could be created in any order. But if someone could help me with the scenario above; am sure I could make a request addressed to any change in the order. :-)

    No this isn't a recursive with clause, perhaps the UNION ALL you got confused. She will work with 10g.

    Since there are 2 tables that you said, the block all_data brings together only the lines of the two tables. table_1 start_date and end_date are built from the event_status (where the max in group by).

Maybe you are looking for