Group by multiply rows - HARD

Hi,
NAME     | SURNAME|     x | y | BIRTH_DAY
KRIS     | ONE     | 324     | 52     | 2011-09-12
KRIS     | SIX     | 222     | 111     | 2011-09-13
KRIS     | SSS     | 1558     | 13     | 2011-09-13
ANNA     | DDD     | 7486     | 0     | 2011-09-12
TOM     | DDD |     4853     | 111     | 2011-09-12
JERRY     | DDD     | 6402     | 112     | 2011-09-12
JACK     | DDD     | 957     | 113     | 2011-09-15
JACK     | DDD     | 11445 |     368     | 2011-09-19
I have problem.
I need to group all this data per name column, so each name needs to have only one row, x must be summed, y must be summed and from surname and birthday column values may be taken randomly. So at the finall I will have one row per one name containig summed values from x and y column and surname and_birthday values may be taken randomly. Examle how it shoul look for KRIS ROW:
KRIS     | SIX     | 546     | 163     | 2011-09-13
For KRIS SURNAME column value six was taken randomly from ONE and SIX values, x and y was summed and value for BIRTH_DAY column was taken randomly from 2011-09-12 and 2011-09-13 dates.
I have no idea how can I do it.
May I ask you for help?
Edited by: user13520646 on 2011-10-10 09:17

(not tested)
select name, min(surname), sum(x) , sum(y), min(birth_day)
from table_name_not_provided
group by name;

Similar Messages

  • Group based on row data

    Given the following data:
    id duration start date end date
    1 15 08/01/2008 10:00 08/01/2008 10:15
    2 15 08/01/2008 10:15 08/01/2008 10:30
    3 15 08/01/2008 10:30 08/01/2008 10:45
    4 15 08/01/2008 11:00 08/01/2008 11:15
    5 15 08/01/2008 11:30 08/01/2008 11:45
    6 15 08/01/2008 11:45 08/01/2008 12:00
    7 15 08/01/2008 12:00 08/01/2008 12:15
    Is it possible to group them based on the sum of the duration column? If three rows' duration sum equals 45 and the datetimes are contiguous, then they'll be grouped as 1. So in the example above, [1 2 3] will be grouped as one and [5 6 7] will be grouped as another - row 4 is excluded since row 4 and row 5 aren't contiguous.
    Thanks.

    How about:
    SQL> alter session set nls_date_format = 'mm/dd/yyyy hh24:mi'
      2  /
    Session altered.
    SQL> with t1 as (
      2              select 1 id,15 duration,to_date('08/01/2008 10:00') start_date,to_date('08/01/2008 10:15') end_date from dual union all
      3              select 2, 15, to_date('08/01/2008 10:15'), to_date('08/01/2008 10:30') from dual union all
      4              select 3, 15, to_date('08/01/2008 10:30'), to_date('08/01/2008 10:45') from dual union all
      5              select 4, 15, to_date('08/01/2008 11:00'), to_date('08/01/2008 11:15') from dual union all
      6              select 5, 15, to_date('08/01/2008 11:30'), to_date('08/01/2008 11:45') from dual union all
      7              select 6, 15, to_date('08/01/2008 11:45'), to_date('08/01/2008 12:00') from dual union all
      8              select 7, 15, to_date('08/01/2008 12:00'), to_date('08/01/2008 12:15') from dual union all
      9              select 8, 45, to_date('08/01/2008 13:00'), to_date('08/01/2008 13:45') from dual union all
    10              select 11, 15, to_date('09/02/2008 08:00'), to_date('09/02/2008 08:15') from dual union all
    11              select 12, 15, to_date('09/02/2008 08:15'), to_date('09/02/2008 08:30') from dual union all
    12              select 13, 15, to_date('09/02/2008 08:30'), to_date('09/02/2008 08:45') from dual union all
    13              select 14, 15, to_date('09/02/2008 08:45'), to_date('09/02/2008 09:00') from dual union all
    14              select 15, 15, to_date('09/02/2008 09:00'), to_date('09/02/2008 09:15') from dual union all
    15              select 16, 15, to_date('09/02/2008 09:15'), to_date('09/02/2008 09:30') from dual union all
    16              select 17, 15, to_date('09/02/2008 09:30'), to_date('09/02/2008 09:45') from dual union all
    17              select 18, 15, to_date('09/02/2008 09:45'), to_date('09/02/2008 10:00') from dual union all
    18              select 19, 15, to_date('09/02/2008 10:00'), to_date('09/02/2008 10:15') from dual union all
    19              select 20, 15, to_date('09/02/2008 10:15'), to_date('09/02/2008 10:30') from dual union all
    20              select 21, 30, to_date('09/02/2008 10:30'), to_date('09/02/2008 11:00') from dual union all
    21              select 22, 15, to_date('09/02/2008 11:00'), to_date('09/02/2008 11:15') from dual
    22             ),
    23       t2 as (
    24              select  id,
    25                      duration,
    26                      start_date,
    27                      end_date,
    28                      case
    29                        when lead(start_date,1,end_date - 1) over(order by id) != end_date then 1
    30                        when duration + lead(duration) over(order by id) > 45 then 1
    31                        when lead(start_date,2,end_date - 1) over(order by id) != lead(end_date) over(order by id) then 2
    32                        when duration + lead(duration) over(order by id) + lead(duration,2) over(order by id) > 45 then 2
    33                        else 3
    34                      end grp_size,
    35                      case
    36                        when lead(start_date,1,end_date - 1) over(order by id) != end_date then duration
    37                        when duration + lead(duration) over(order by id) > 45 then duration
    38                        when lead(start_date,2,end_date - 1) over(order by id) != lead(end_date) over(order by id) then duration + lead(duration) over(order by id)
    39                        when duration + lead(duration) over(order by id) + lead(duration,2) over(order by id) > 45 then duration + lead(duration) over(order by id)
    40                        else duration + lead(duration) over(order by id) + lead(duration,2) over(order by id)
    41                      end grp_duration,
    42                      row_number() over(order by id) rn
    43                from  t1
    44             ),
    45       t3 as (
    46              select  id,
    47                      level grp_number,
    48                      grp_duration
    49                from  t2
    50                start with id = 1
    51                connect by rn = prior rn + prior grp_size
    52             )
    53  select     t1.*,
    54          max(t3.grp_number) over(order by t1.id) grp_number,
    55          last_value(t3.grp_duration ignore nulls) over(order by t1.id) grp_duration
    56    from     t1,
    57          t3
    58    where t1.id = t3.id(+)
    59    order by t1.id
    60  /
            ID   DURATION START_DATE       END_DATE         GRP_NUMBER GRP_DURATION
             1         15 08/01/2008 10:00 08/01/2008 10:15          1           45
             2         15 08/01/2008 10:15 08/01/2008 10:30          1           45
             3         15 08/01/2008 10:30 08/01/2008 10:45          1           45
             4         15 08/01/2008 11:00 08/01/2008 11:15          2           15
             5         15 08/01/2008 11:30 08/01/2008 11:45          3           45
             6         15 08/01/2008 11:45 08/01/2008 12:00          3           45
             7         15 08/01/2008 12:00 08/01/2008 12:15          3           45
             8         45 08/01/2008 13:00 08/01/2008 13:45          4           45
            11         15 09/02/2008 08:00 09/02/2008 08:15          5           45
            12         15 09/02/2008 08:15 09/02/2008 08:30          5           45
            13         15 09/02/2008 08:30 09/02/2008 08:45          5           45
            ID   DURATION START_DATE       END_DATE         GRP_NUMBER GRP_DURATION
            14         15 09/02/2008 08:45 09/02/2008 09:00          6           45
            15         15 09/02/2008 09:00 09/02/2008 09:15          6           45
            16         15 09/02/2008 09:15 09/02/2008 09:30          6           45
            17         15 09/02/2008 09:30 09/02/2008 09:45          7           45
            18         15 09/02/2008 09:45 09/02/2008 10:00          7           45
            19         15 09/02/2008 10:00 09/02/2008 10:15          7           45
            20         15 09/02/2008 10:15 09/02/2008 10:30          8           45
            21         30 09/02/2008 10:30 09/02/2008 11:00          8           45
            22         15 09/02/2008 11:00 09/02/2008 11:15          9           15
    20 rows selected.
    SQL> SY.

  • Dispaly radio group in a row

    I want to display radio group in one row like
    o YES o NO
    The default renderer "<jbo:InputRender" is showing it in two rows like this
    <INPUT TYPE="RADIO" BLA BLA.......">Yes<BR>
    <INPUT TYPE="RADIO" BLA BLA........">No<BR>
    Any suggestions ?

    I think you might have posted this in the wrong forum.
    It looks like you meant to post it in the JDeveloper forum:
    JDeveloper and ADF

  • Create a group based on row count

    I am looking for a way of reducing the size of tables I am displaying in my monthly report, by counting some rows together, and naming them 'other'
    I would like to always show all rows, where count of item is >= 50, but all rows where count of item < 50, total up and call 'other'.  I will add an example image as soon as my account has been verified
    I can hide rows using this in the visibility =iif(Count(Fields!Item.Value) >= 50, False, True)
    I have duplicated the line, and added a filter to each (one for greater than 50, one for less than 50) but my totals are still counting all the data, and not just the filtered data.
    Ideally, I would like to add a column using something like =iif(Count(Fields!Item.Value) >= 50, "Over50", "Under50"), or a group based on the same sort of idea, but I keep getting errors about using aggregates in columns.
    Any suggestions?
    Cheers

    What you can do is to add derived column in query behind like this
    SELECT other columns...,
    CASE WHEN Cnt >= 50 THEN YourGroupingField ELSE 'Other' END AS GrpName
    FROM
    SELECT *,COUNT(1) OVER (PARTITION BY YourGroupingField) AS Cnt
    FROM Table
    )t
    Then in your reports use =Fields!GrpName.Value as the Grouping column and you will get required output
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Grouping of two rows of internal table

    Hi all,
    I am having a requirement in which I want to group two rows of an internal table and assign a pointer to the two rows.
    This pointer variable will then be passed to ALV.
    Help reqd.
    regards.

    Hi Gaurav,
    Hope the below code helps:
    TYPES :BEGIN OF TY_ITAB2,
    DATA(400),
    END OF TY_ITAB2.
    DATA: ITAB3 TYPE TY_ITAB2 OCCURS 0 WITH HEADER LINE
    Loop at itab1.
    ITAB3-DATA = ITAB1-LABEL.
    APPEND ITAB3.
    ITAB3-DATA = ITAB1-MATNR.
    APPEND ITAB3.
    endloop.
                        or
    You can create a deep internal table. You can declare one Column as an internal table and store the NOTES in that Internal table for each row.
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb366d358411d1829f0000e829fbfe/content.htm
    you can check the example in the link
    Kindly Reward Points If You Find The Reply Helpful.
    Cheers,
    Chaitanya.

  • How to use Group by in Row SSRS

    Hi All;
    I have done Fetch XML report in SSRS as below
    Waiting time column has the expreesion as
    = SWITCH ( DateDiff("d",Fields!crmi_ebevent_createdon.Value,Fields!crmi_ebstartdate.Value)
    < 0, "Less Than 0",
    DateDiff("d",Fields!crmi_ebevent_createdon.Value,Fields!crmi_ebstartdate.Value) <= 5, "0 - 5",
    DateDiff("d",Fields!crmi_ebevent_createdon.Value,Fields!crmi_ebstartdate.Value) <= 10, "6 - 10",
    DateDiff("d",Fields!crmi_ebevent_createdon.Value,Fields!crmi_ebstartdate.Value) <= 15, "11 - 15",
    DateDiff("d",Fields!crmi_ebevent_createdon.Value,Fields!crmi_ebstartdate.Value) <= 20, "16 - 20",
    DateDiff("d",Fields!crmi_ebevent_createdon.Value,Fields!crmi_ebstartdate.Value) <= 25, "21 - 25",
    DateDiff("d",Fields!crmi_ebevent_createdon.Value,Fields!crmi_ebstartdate.Value) <= 30, "26 - 30",
    DateDiff("d",Fields!crmi_ebevent_createdon.Value,Fields!crmi_ebstartdate.Value) > 30, "'More than 30")
    I need to group the table  with same expreesion on Row Groups - Details1
    Any help very much appreciated
    Thanks
    Pradnya07

    Hi Pradnya07,
    If I understand correctly, you want to add a group grouped by the same expression you post in the table. In this scenario, we can refer to the steps below to achieve the requirement:
    In the Row Groups pane, right-click the (Details) group to add a Parent Group.
    Type the same expression in the drop-down list of Group by option.
    Click “OK”, it will automatically add a group named Group1 in the Row Groups. Then the table will be split to 8 groups.
    The following screenshot is for your reference:
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Group Totals and row values to be repeated

    All,
    I have a data set like this
    Category     YearMonth     Section      Count1      Count2
    Category1     201401           S1              15              
    5
    Category1     201401           S2              10              
    0
    Category1     201402           S1                5               5
    Below is the result set that I want:
    Category     YearMonth     Section     %Count2
    Category1     201401           S1               16.66% i.e. (5/30) * 100     (30, because if you
    look at YearMonth 201401, I want to have a sum of 15 + 5 + 10 ))
    Category1     201401           S2                (0/30) * 100 = 0%          
    Category1     201402           S1                (5/10) * 100 = 50% (Division by 10, coz the sum of counts for 201402 is 5 + 5)

    Hi SqlCraze,
    According to your description, you want to calculate a percentage of Count1 in Total Counts. Right?
    In this scenario, we can set the detail rows group on YearMonth. Since we can specify scope for sum function, so we can get the total counts value for each group and calculate the percentage. please try the following expression:
    =Fields!Count2.Value/(Sum(Fields!Count1.Value,"YearMonth")+Sum(Fields!Count2.Value,"YearMonth"))
    We have tested this scenario, the design and result look like below:
    Reference:
    Sum Function (Report Builder and SSRS)
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • How to display multiply rows

    hi i have 3 label and one inputtext in a row how can i display this 12 time like having 12 rows not only displaying the first record from the table
    this is my xml
    <af:panelGroupLayout layout="scroll" id="pgl3">
                                                        <af:panelHeader text="Months" id="ph2"
                                                                        inlineStyle="height:302px; border-color:Navy; border-style:ridge; width:360px;">
                                                            <f:facet name="context"/>
                                                            <f:facet name="menuBar"/>
                                                            <f:facet name="toolbar"/>
                                                            <f:facet name="legend"/>
                                                            <f:facet name="info"/>
                                                            <af:panelFormLayout id="pfl3"
                                                                                inlineStyle="width:299px; height:238px;"
                                                                                labelAlignment="top" rows="1"
                                                                                maxColumns="10">
                                                                <f:facet name="footer">
                                                                    <af:group id="g1">
                                                                        <af:inputText value="#{bindings.Id.inputValue}"
                                                                                      label="#{bindings.Id.hints.label}"
                                                                                      required="#{bindings.Id.hints.mandatory}"
                                                                                      columns="#{bindings.Id.hints.displayWidth}"
                                                                                      maximumLength="#{bindings.Id.hints.precision}"
                                                                                      shortDesc="#{bindings.Id.hints.tooltip}"
                                                                                      id="id" visible="false">
                                                                            <f:validator binding="#{bindings.Id.validator}"/>
                                                                            <af:convertNumber groupingUsed="false"
                                                                                              pattern="#{bindings.Id.format}"/>
                                                                        </af:inputText>
                                                                        <af:inputText value="#{bindings.MonId.inputValue}"
                                                                                      label="#{bindings.MonId.hints.label}"
                                                                                      required="#{bindings.MonId.hints.mandatory}"
                                                                                      columns="#{bindings.MonId.hints.displayWidth}"
                                                                                      maximumLength="#{bindings.MonId.hints.precision}"
                                                                                      shortDesc="#{bindings.MonId.hints.tooltip}"
                                                                                      id="it7" partialTriggers="id"
                                                                                      visible="false">
                                                                            <f:validator binding="#{bindings.MonId.validator}"/>
                                                                            <af:convertNumber groupingUsed="false"
                                                                                              pattern="#{bindings.MonId.format}"/>
                                                                        </af:inputText>
                                                                    </af:group>
                                                                </f:facet>
                                                                <af:panelLabelAndMessage label="#{bindings.MonthNo.hints.label}"
                                                                                         id="plam4">
                                                                    <af:outputText value="#{bindings.MonthNo.inputValue}"
                                                                                   id="ot1">
                                                                        <af:convertNumber groupingUsed="false"
                                                                                          pattern="#{bindings.MonthNo.format}"/>
                                                                    </af:outputText>
                                                                </af:panelLabelAndMessage>
                                                                <af:panelLabelAndMessage label="#{bindings.Name.hints.label}"
                                                                                         id="plam5">
                                                                    <af:outputText value="#{bindings.Name.inputValue}"
                                                                                   id="ot2"/>
                                                                </af:panelLabelAndMessage>
                                                                <af:inputDate value="#{bindings.MonthEndDt.inputValue}"
                                                                              label="#{bindings.MonthEndDt.hints.label}"
                                                                              required="#{bindings.MonthEndDt.hints.mandatory}"
                                                                              columns="10"
                                                                              shortDesc="#{bindings.MonthEndDt.hints.tooltip}"
                                                                              id="id4">
                                                                    <f:validator binding="#{bindings.MonthEndDt.validator}"/>
                                                                    <af:convertDateTime pattern="#{bindings.MonthEndDt.format}"/>
                                                                </af:inputDate>
                                                                <af:panelLabelAndMessage label="#{bindings.ClosedDt.hints.label}"
                                                                                         id="plam6">
                                                                    <af:outputText value="#{bindings.ClosedDt.inputValue}"
                                                                                   id="ot3">
                                                                        <af:convertDateTime pattern="#{bindings.ClosedDt.format}"/>
                                                                    </af:outputText>
                                                                </af:panelLabelAndMessage>
                                                            </af:panelFormLayout>
                                                            <af:commandButton actionListener="#{bindings.Commit.execute}"
                                                                              text="CloseMonth"
                                                                              id="cb5"/>
                                                            <af:inputText value="#{bindings.Id.inputValue}"
                                                                          label="#{bindings.Id.hints.label}"
                                                                          required="#{bindings.Id.hints.mandatory}"
                                                                          columns="#{bindings.Id.hints.displayWidth}"
                                                                          maximumLength="#{bindings.Id.hints.precision}"
                                                                          shortDesc="#{bindings.Id.hints.tooltip}" id="it8"
                                                                          visible="false">
                                                                <f:validator binding="#{bindings.Id.validator}"/>
                                                                <af:convertNumber groupingUsed="false"
                                                                                  pattern="#{bindings.Id.format}"/>
                                                            </af:inputText>
                                                            <af:inputText value="#{bindings.MonId.inputValue}"
                                                                          label="#{bindings.MonId.hints.label}"
                                                                          required="#{bindings.MonId.hints.mandatory}"
                                                                          columns="#{bindings.MonId.hints.displayWidth}"
                                                                          maximumLength="#{bindings.MonId.hints.precision}"
                                                                          shortDesc="#{bindings.MonId.hints.tooltip}"
                                                                          id="it9" partialTriggers="it8" visible="false">
                                                                <f:validator binding="#{bindings.MonId.validator}"/>
                                                                <af:convertNumber groupingUsed="false"
                                                                                  pattern="#{bindings.MonId.format}"/>
                                                            </af:inputText>
                                                        </af:panelHeader>
                                                    </af:panelGroupLayout>

    hi i use this iterator but am geting a blank screen when i run my jsp page am in jdeveloper 11.1.2.1.0
    my code is
    <af:iterator var="row" first="3" rows="25" varStatus="stat">
                                                    <af:inputText value="#{bindings.UserId1.inputValue}"
                                                                  label="#{bindings.UserId1.hints.label}"
                                                                  required="#{bindings.UserId1.hints.mandatory}"
                                                                  columns="10"
                                                                  maximumLength="#{bindings.UserId1.hints.precision}"
                                                                  shortDesc="#{bindings.UserId1.hints.tooltip}" id="it1">
                                                        <f:validator binding="#{bindings.UserId1.validator}"/>
                                                    </af:inputText>
                                                    <af:inputText value="#{bindings.Name1.inputValue}"
                                                                  label="#{bindings.Name1.hints.label}"
                                                                  required="#{bindings.Name1.hints.mandatory}"
                                                                  columns="10"
                                                                  maximumLength="#{bindings.Name1.hints.precision}"
                                                                  shortDesc="#{bindings.Name1.hints.tooltip}" id="it2">
                                                        <f:validator binding="#{bindings.Name1.validator}"/>
                                                    </af:inputText>
                                                    <af:inputText value="#{bindings.Surname1.inputValue}"
                                                                  label="#{bindings.Surname1.hints.label}"
                                                                  required="#{bindings.Surname1.hints.mandatory}"
                                                                  columns="10"
                                                                  maximumLength="#{bindings.Surname1.hints.precision}"
                                                                  shortDesc="#{bindings.Surname1.hints.tooltip}" id="it3">
                                                        <f:validator binding="#{bindings.Surname1.validator}"/>
                                                    </af:inputText>
                                                    <af:inputText value="#{bindings.Fax.inputValue}"
                                                                  label="#{bindings.Fax.hints.label}"
                                                                  required="#{bindings.Fax.hints.mandatory}"
                                                                  columns="10"
                                                                  maximumLength="#{bindings.Fax.hints.precision}"
                                                                  shortDesc="#{bindings.Fax.hints.tooltip}" id="it4">
                                                        <f:validator binding="#{bindings.Fax.validator}"/>
                                                    </af:inputText>
                                                    <af:inputText value="#{bindings.Phone.inputValue}"
                                                                  label="#{bindings.Phone.hints.label}"
                                                                  required="#{bindings.Phone.hints.mandatory}"
                                                                  columns="10"
                                                                  maximumLength="#{bindings.Phone.hints.precision}"
                                                                  shortDesc="#{bindings.Phone.hints.tooltip}" id="it5">
                                                        <f:validator binding="#{bindings.Phone.validator}"/>
                                                    </af:inputText>
                                                    </af:iterator>
                                                </af:panelFormLayout>
                                            </af:panelGroupLayout>

  • Query to get a group having n rows each

    I have emp table empl_id in sorted order and i need column value "Group no"  based on value of N. (making a group start with 1 having n employees each)
    N=2
    emp_id    Name   Group No
    1001          A            1
    1003         B             1
    1004         C             2
    1006         D             2
    1007         E             3
    1009         F             3
    N=3
    emp_id    Name   Group No
    1001          A            1
    1003         B             1
    1004         C             1
    1006         D             2
    1007         E             2
    1009         F             2
    Your SQL is highly appricated.

    Hi,
    Since I don't have a sample version of your table, I'll use scott.emp.
    Here's one way:
    VARIABLE  n   NUMBER
    EXEC     :n := 3;
    SELECT    empno, ename
    ,         CEIL ( ROW_NUMBER () OVER (ORDER BY ename)
                   / :n
                   )       AS group_no
    FROM      scott.emp
    ORDER BY  ename
    The highest-numbered group may have fewer members than the others.  For example, scott.emp has 14 rows.  There's no way to assign every row to a single group and have 3 members in each group; there is no integer X such that 3 * X = 14.  So the query above assigns 3 members to group_nos 1 through 4, but only assigns 2 rows to group_no=5.

  • Hiding item renders in Group Datagrid Label Rows?

    I have an Advanced data grid displaying a grouped collection.  I have an item renderer in one column the is a canvas with a button that is bound to the data.
    However, buttons are also showing on the header rows, where they are not needed (see below).  How do I fix this?

    I have an Advanced data grid displaying a grouped collection.  I have an item renderer in one column the is a canvas with a button that is bound to the data.
    However, buttons are also showing on the header rows, where they are not needed (see below).  How do I fix this?

  • How to add blank rows between groups of duplicate rows?

    here is my setup
    create table #tmpA(rowID int identity(1,1), fName varchar(10), lName varchar(10))
    insert into #tmpA
    select 'a', 'b' union all
    select 'a', 'b' union all
    select 'c', 'd' union all
    select 'c', 'd' union all
    select 'e', 'f' union all
    select 'e', 'f' union all
    select 'g', 'h' union all
    select 'g', 'h'
    select distinct fName, lName
    into #tmpB
    From #tmpA
    select t1.* from #tmpA t1 Join #tmpB t2 on t1.fName = t2.fName and t1.lName = t2.lName
    --output
    rowID  fName  lName
    1             a         b
    2             a         b
    3             c         d
    4             c         d
    5             e         f
    6             e         f
    7             g         h
    8             g         h
    I want to add blank rows between rows 2 & 3 and between rows 4 & 5 and between rows 6 & 7 in the join query above.  Is there Tsql that can accomplish something like this to make the join query result look like the following output?
    rowID  fName  lName
    1            a          b
    2            a          b
    3            c          d
    4            c          d
    5            e          f
    6            e          f
    7            g          h
    8            g          h
    or if this is not possible I could go with an output like this:
    rowID  fName  lName
    1             a         b
    2             a         b
    3
    4             c         d
    5             c         d
    6
    7             e         f
    8             e         f
    9
    10           g         h
    11           g         h
    Rich P

    I came up with the following on my own.  I was just hoping there might be a fancier way to do this - like without looping -- and yes, I could/should do this in a presentation layer, but I just wanted to do this in Query Analyzer (or whatever they call
    it now -- SSMS ...) -- BTW, thanks CELKO for the suggestion about how to insert multiple rows using Values -- works great.
    If (object_id('tempdb..#tmpA') is not null) drop table #tmpA
    If (object_id('tempdb..#tmpC') is not null) drop table #tmpC
    create table #tmpA(rowID int identity(1,1), fName varchar(10), lName varchar(10))
    insert into #tmpA
    values
    ('a','b'),
    ('a','b'),
    ('c','d'),
    ('c','d'),
    ('e','f'),
    ('e','f'),
    ('g','h'),
    ('g','h')
    create table #tmpC(rrowID int Identity(1,1), rowID int, fName varchar(10), lName varchar(10))
    declare @i int, @s varchar(10), @t varchar(10), @u varchar(10), @v varchar(10)
    select @i = min(rowID) from #tmpA
    set @u = 'xx'
    While (@u != 'yy')
    Begin
       select @s = fName, @t = lName from #tmpA Where rowID = @i
       if exists(select 1 from #tmpA Where rowID = @i + 1)
          select @u = fname, @v = lName From #tmpA Where rowID = @i + 1
       else
          set @u = 'yy'
        if @s = @u And @t = @v
           begin  
             Insert Into #tmpC(rowID, fName, lName) Select * from #tmpA Where rowID = @i
             Insert Into #tmpC(rowID, fName, lName) Select * from #tmpA Where rowID = @i + 1
           end      
        else
           begin
              Insert Into #tmpC(rowID, fName, lName) Select null, '', ''  
           end
        set @i = @i + 1
    End
    select * from #tmpC
    --output from #tmpC
    rrowID  rowID  fName  lName
      1            1         a        b
      2            2         a        b
      3          NULL 
      4            3         c        d
      5            4         c        d
      6          NULL  
      7             5         e        f
      8             6         e        f
      9           NULL  
      10           7          g        h
      11           8          g        h
      12         NULL  
    Rich P

  • Search groups with multiple rows into a sngle row

    Hey all I have a view similar to the one below what I am trying to do is get the projects that have been fully completed. Meaning all items in that order have been sent. If there is an assignment within that project that has only been partially completed that that order must not show.
    Project ID || assignment ID || status
    100 1001 COMPLETE
    100 1002 COMPLETE
    100 1003 COMPLETE
    100 1004 COMPLETE
    200 2001 NOT COMPLETE
    200 2002 COMPLETE
    300 3001 COMPLETE
    300 3002 COMPLETE
    300 3003 COMPLETE
    400 4001 COMPLETE
    The result should be
    Project ID
    100
    300
    400

    <> sign in Todd's query means that result of subquery should be all rows where value in status column is differ from "COMPLETE" for related id in main query. If at least one row will have value other than "COMPLETE" condition will be failed and value in main query will not be returned.
    Peter D.

  • Easy way for group moving multiple rows to insert under new row?

    Hi All.
    I have been trying to find a way that will let me move - say - 20 rows (#'s 105 - 125) each with 15 columns to a space that fits under an existing column that may be further up - say - row 5. I would like to do this in a way that does not require my creating 20 rows under row 5 in order for there to be more space between row 5 that has data in it and row 6 or 7 that may have data in it.
    Right now I am creating a row, creating another row, multiple selecting these two rows and hitting down arrow to create new rows two by two ten times.
    I have a case now where I would like to start moving organized pieces of information around that have 40 to 100 rows of data and it is becoming increasingly inconvenient to have to do this.
    Thanks for any tips, tricks, pointers etc.

    Jon,
    This takes some patience and some practice.
    Click on the first Row label and Shift-Click on the last Row Label of the range of rows you want to move.
    Now you have a large selection. Here comes the delicate part that may take some practice. Make sure your work is saved before you begin practicing. Read these instructions thoroughly before you begin.
    Hover over a label in the selected range of rows. Click and drag to the left, pulling the selected rows off the main table. Hold on to the mouse switch and don't let go yet. Now move the selection that you have a hold of back over the main table and watch the horizontal lines that separate the rows. You will find that double lines appear under the cursor. This indicates where your selection will be inserted if you let go right now. Move your pointer up or down the table until you come to where you want your selection to go and then release the mouse.
    Jerry

  • SOLVED: Grouping to Single Row

    I am using version 5.6.2 with EBS 11.5.10.2 through concurrent requests.
    I have output that is grouped by the field G_PAGE_BREAK and I would like to return the lowest and highest value of PBDATA on one line. In the following example it would be "58 to 60".
    The XML looks like this:
    <LIST_G_PAGE_BREAK>
    <G_PAGE_BREAK>
    <PBDATA>58</PBDATA>
    </G_PAGE_BREAK>
    <G_PAGE_BREAK>
    <PBDATA>59</PBDATA>
    </G_PAGE_BREAK>
    <G_PAGE_BREAK>
    <PBDATA>60</PBDATA>
    </G_PAGE_BREAK>
    </LIST_G_PAGE_BREAK>
    My template uses the following:
    <?for-each-group:LIST_G_PAGE_BREAK;G_PAGE_BREAK?>
    <?for-each-group:current-group();./PBDATA?>
    <?xdoxslt:minimum(PBDATA)?> to <?xdoxslt:maximum(PBDATA)?>
    <?end for-each-group?>
    <?end for-each-group?>
    This is giving me three lines instead of one. Can anyone see where I've gone wrong?
    Thanks,
    Ed

    Hey Ed,
    use this
    <?for-each: LIST_G_PAGE_BREAK?>
    Max == <?xdoxslt:maximum(./G_PAGE_BREAK/PBDATA)?>
    Min == <?xdoxslt:minimum(./G_PAGE_BREAK/PBDATA)?>
    <?end-for-each?>

  • Can I sort a column based upon a "find" word?  i.e. I want to group all the rows that contain a certain word.  I'm using Numbers '09 on a Macbook Pro.  Thanks for your help!

    A second question: I am creating a database of products for my point of sale system.  I am using a product list sent to me by a vendor.  Can I pull out certain words in their description and add them to a new column.  i.e. The vendors' description in one cell is "Blueridge Guitar Dreadnought."  Can I automatically add the word "Dreadnought" to a new column in the same row?

    You can extract the word case where the string contains case using
    =IFERROR(IF(FIND("CASE",B)>0,"CASE",""),"")
    But that doesn't solve the issue of what goes in that column for lines where the product ins not a case.
    Looking at the other columns, I don't see a means of getting "Hardshell" from the given data using a formula.
    A semi-manual method using the "Show rows... feature of the Reorganize panel might prove efficient.
    Here, the Show rows... displayd was applied, then CASE was entered in the first cell in column A and filled down to the last visible cell. As can be seen below, the fill operation placed "CASE" in only the rows where column B containsed "CASE".
    Regards,
    Barry

Maybe you are looking for

  • [Solved] Hp-setup cannot find my HP Photosmart Plus printer

    Hi all, I'm trying to set up my HP Photosmart Plus printer. I have an Arch desktop acting as the CUPS server, which I ssh into from my laptop. I've gone through the CUPS installation and linux - linux sharing instructions. When I try to set up the pr

  • Why can't I open the apple store on my iPhone

    First let me say this is a phone I got sent from Apple. The issue I have is when using my extension cable once fully charged my phone says charging is not supported with this accessory. Next issue I have is I can't log into the App Store on my phone.

  • G\L Account determination per itemgroup

    Hello, I do have a question about the G\L Account determination in SAP B1. It is my task to find out which G\L Account(s) is/are being used by the program for all different kind of (trans)actions. I checked out help.sap.com to check out the different

  • IDVD can't find my Favorite Themes

    I've defined several of my own themes, and iDVD 6 can't find them. By this I mean that it finds them okay when I want to apply a theme to a menu, and everything is fine until I save the project. But when I try to reopen the project, I consistently ge

  • Advice on upgrading

    Hello all- So, I've gotten a bit tired of all of the capture problems related to new versions of Quicktime, etc. (I'm still on FCP 4.5). I'm now prepared to upgrade in the hopes that it will eliminate these headaches. My question is - what do I "need