How to combine many rows into one row

Hi all,
I have a question regarding to how to combine many rows into one row?
My result set is like that:
ITEM_NO NAME1
11 abc
11 cde
11 fg
Want to combine them into
ITEM_NO NAME1
11 abc;cde;fg
would anybody can tell me how to do that? Thanks
Ray

You can check this --
satyaki>
satyaki>
satyaki>create table t
  2  as
  3      select 11 ITEM_NO, 'abc' NAME1 from dual
  4      union all
  5      select 11 ITEM_NO, 'cde' NAME1 from dual
  6      union all
  7      select 11 ITEM_NO, 'fg' NAME1 from dual;
Table created.
satyaki>
satyaki>
satyaki>
satyaki>set lin 10
satyaki>
satyaki>desc t;
Name              Null?    Type
ITEM_NO                    NUMBER
NAME1                      VARCHAR2(3)
satyaki>
satyaki>
satyaki>set lin 1000
satyaki>
satyaki>
satyaki>
satyaki>SELECT ITEM_NO,
  2         LTRIM(MAX(SYS_CONNECT_BY_PATH(NAME1,';'))
  3         KEEP (DENSE_RANK LAST ORDER BY curr),';') AS NAME1_DET
  4  FROM   (SELECT ITEM_NO,
  5                 NAME1,
  6                 ROW_NUMBER() OVER (PARTITION BY ITEM_NO ORDER BY NAME1) AS curr,
  7                 ROW_NUMBER() OVER (PARTITION BY ITEM_NO ORDER BY NAME1) -1 AS prev
  8          FROM   t)
  9  GROUP BY ITEM_NO
10  CONNECT BY prev = PRIOR curr AND ITEM_NO = PRIOR ITEM_NO
11  START WITH curr = 1;
   ITEM_NO  NAME1_DET
        11  abc;cde;fgRegards.
Satyaki De.

Similar Messages

  • Merging rows into one row but into SEPARATE Columns

    Hello Gurus,
    I have searched alot on OTN and many other places, but no where I could get the solution of how can we merge rows into one row but separate column. For example
    Consider the below scenario
    "DEPARTMENT", "EMP","NAME","SUBJECT"
    "Electronics","1","Sam","LIC"
    "Electronics","2","Pam","VLSI"
    "Electronics","3","Tom","C"
    "Mech","1","Abu","Thermo"
    "Mech","4","Lina","Machines"Now, I need the output like
    Based on Department as Group By Clause
    "DEPARTMENT", "EMP1","NAME1","SUBJECT1","EMP2","NAME2","SUBJECT2","EMP3","NAME3","SUBJECT3"
    "Electronics","1","Sam","LIC","2","Pam","VLSI","3","Tom","C"
    "Mech","1","Abu","Thermo","4","Lina","Machines"
    The row data to be loaded into separate columns. Name of the column is not an issue... can be anythingIn all the forums which I went through I could find them loading into a single column, but not into respective separate columns.
    Any help would be much appreciated.
    Thanks

    848265 wrote:
    Frank,
    I saw your name nearly n number of times, as I went through many forums today... And the link which you have just posted, I went through it today afternoon.
    Could you please explain this bit taken from your dynamic pivot post.
    SELECT     DISTINCT
         ',     COUNT (CASE WHEN job = '''
    ||     job
    ||     ''' '     AS txt1
    ,     'THEN 1 END)     AS '
    ||     job
    ||     '_CNT'     AS txt2
    FROM     scott.emp
    ORDER BY     txt1;Many Thanks.You only need that when you need column aliases based on the actual data (and you explicitly said you don't need that) or when can't put an upper bound on the number of columns to be displayed. If that doesn't apply to this problem, then don't use any kind of dynamic SQL (like the code above); it makes the job much more difficult, less efficient and less robust.
    Here's what the code above is doing.
    If you were hard-coding a query that showed the number of people in each job, and you knew that the possible jobs were 'ANALYST', 'CLERK' and 'MANAGER', then you might hard-code a query like this:
    SELECT    deptno
    ,       COUNT (CASE WHEN job = 'ANALYST'  THEN 1 END)     AS analyst
    ,       COUNT (CASE WHEN job = 'CLERK'    THEN 1 END)     AS clerk
    ,       COUNT (CASE WHEN job = 'MANAGER'  THEN 1 END)     AS manager
    FROM       scott.emp
    GROUP BY  deptno
    ;If the jobs had different names, or if there were not 3 different jobs, then you would have to change the lines in the SELECT clause that start with ", COUNT ( CASE ...".
    The code you posted is from an example of dynamic SQL, where you first run a Preliminary Query . (What you posted above is, in fact, the complete preliminary query.) The output of that preliminary query is exactly the variable part of the real query, such as:
    ,       COUNT (CASE WHEN job = 'ANALYST'  THEN 1 END)     AS analyst
    ,       COUNT (CASE WHEN job = 'CLERK'    THEN 1 END)     AS clerk
    ,       COUNT (CASE WHEN job = 'MANAGER'  THEN 1 END)     AS managerYou then use this output as part of your main query. In other words, you can write something today that will generate exacrly as many columns as you need next year, with names from the data as it is next year. How? because you're not writing the full query today. The variable part will be written by the preliminary query when it runs next year.

  • A way to roll up rows into one row

    Is there a way to "roll up" a set number of rows into one row? I would like to have a row that can be expanded into several rows by clicking a plus sign or something similar. Anyway to do this?
    Regards,
    Mark

    Mark,
    Sorry, it didn't occur to me that you meant "hiding". It sounds like you already know how to hide and unhide but unfortunately there are no shortcuts. I agree that it would be nice to have a way to unhide a selected row or column and if my memory serves me I submitted a request for this feature some months ago. May I suggest that you also go to Main Menu > Numbers > Provide Numbers Feedback.
    The more requests for features they receive the better the chance for getting them in future updates. Best wishes,
    pw

  • How to combine mutiple tracks into one album in itunes 12

    How to combine mutiple tracks into one album in itunes 12

    Make sure they all have the same Album Artist and Album Name.

  • HT4059 I'm trying to organize my PDFs in iBooks on my ipad2 and I can't figure out how to combine multiple PDFs into one. Any thoughts?

    I'm trying to organize my PDFs in iBooks on my ipad2 and can't figure out how to combine multiple PDFs into one. Any thoughts?

    I'm trying to organize my PDFs in iBooks on my ipad2 and can't figure out how to combine multiple PDFs into one. Any thoughts?

  • Combining like results into one row

    The statement below works. However when the results are returned there are multiple values returned for the same "Period" that I would like to see returned into one row.
    SELECT "Request ID", "External Customer", "Staff Prof Id", "Period", "Planned External", "Actual External", "Planned Internal", "Actual Internal", "Total Planned", "Actual Total"
    FROM (
    SELECT ppl.request_id "Request ID", ppl.mdpr_bds_ext_customer "External Customer", cells.staff_prof_id "Staff Prof Id", period.period_short_name "Period", CELLS.PLANNED_FTE/100 "Planned External", CELLS.actual_fte/100 "Actual External", 0 "Planned Internal", 0 "Actual Internal", /*skills.skill_name,*/ total.plan_total_fte/100 "Total Planned", total.actual_total_fte/100 "Actual Total"
    FROM RML.MREQ_MDPR_PROJ PPL, knta.krsc_staff_prof_line_cells_v CELLS, knta.krsc_staff_prof_lines_v LINES, knta.knta_periods PERIOD, knta.krsc_skills_v SKILLS, knta.krsc_staff_prof_period_sum TOTAL
    where PPL.MDPR_BDS_SUB_PROJ IS NOT NULL AND PPL.KNTA_STAFFING_PROFILE = CELLS.STAFF_PROF_ID(+) AND cells.staff_prof_line_id = lines.staff_prof_line_id AND ppl.knta_staffing_profile = total.staff_prof_id
    AND cells.period_id = period.period_id AND lines.skill_id = skills.skill_id AND skills.skill_name like '%External%' AND total.period_id = period.period_id
    UNION
    SELECT ppl.request_id "Request ID", ppl.mdpr_bds_ext_customer "External Customer", cells2.staff_prof_id "Staff Prof Id", period.period_short_name "Period", 0 "Planned External", 0 "Actual External", CELLS2.planned_fte/100 "Planned Internal", CELLS2.actual_fte/100 "Actual Internal", /*skills.skill_name,*/ total.plan_total_fte/100 "Total Planned", total.actual_total_fte/100 "Actual Total"
    FROM RML.MREQ_MDPR_PROJ PPL, knta.krsc_staff_prof_line_cells_v CELLS2, knta.krsc_staff_prof_lines_v LINES, knta.knta_periods PERIOD, knta.krsc_skills_v SKILLS, knta.krsc_staff_prof_period_sum TOTAL
    where PPL.MDPR_BDS_SUB_PROJ IS NOT NULL AND PPL.KNTA_STAFFING_PROFILE = CELLS2.STAFF_PROF_ID(+) AND cells2.staff_prof_line_id = lines.staff_prof_line_id AND ppl.knta_staffing_profile = total.staff_prof_id
    AND cells2.period_id = period.period_id AND lines.skill_id = skills.skill_id AND skills.skill_name not like '%External%' AND total.period_id = period.period_id)
    ORDER BY "Request ID"

    Probably you are looking at something like GROUP BY "Request ID", "External Customer", "Staff Prof Id", "Period" and SUM () the other columns. As Enrico says, examples of actual and desired output would be helpful.
    At a glance a UNION of...
    AND    skills.skill_name LIKE '%External%'...and...
    AND    skills.skill_name NOT LIKE '%External%'...seems a slightly strange approach.

  • Combining multiple rows into one row

    Hi all.
    My most humble apology for this question but solutions in previous threads did not seem to help much.
    Apparently, my account has not been verified and I am currently at home with no access to the SQL code so i can't post the actual code.
    We have this (mockup) of code
    Select S.C1, AViewSS.Study, AViewSS.SlotName, IST.TakenByDate, IST.ScannedByTime, SE.TimepointCalculation
    From IST
    INNER JOIN
    AViewSS ON IST.GroupID = AViewSS.GroupID and
    IST.SlotID = AViewSS.SlotID
    INNER JOIN
    S ON AViewSS.StudyID = S.StudyID
    INNER JOIN
    SE ON IST.Line = SE.Line and IST.SubLine = SE.SubLine and
    AViewSS.ScheduleID = SE.ScheduleID
    WHERE
    (IST.GroupID = 92) and (IST.SlotID between 1791 and 1795)
    and (AViewSS.VisitID = 137)
    The query currently returns this result set
    Col 1   Col 2   Taken Date  Date 1                Date 2               Date 3             
    Scanned DateTime
    Data    Data    3/12/2015  3/12/2015 7:22                                   
                    3/12/2015 7:22
    Data    Data    3/12/2015                            3/12/2015 8:47                         
    3/12/2015 8:47
    Data    Data    3/12/2015                                                    
    3/12/2015 9:27 3/12/2015 9:27
    Data    Data    3/22/2015                            3/22/2015 7:27        
                     3/22/2015 7:27
    Data    Data    3/22/2015
    Data    Data    4/12/2015
    Data    Data    4/12/2015
    Data    Data    4/12/2015
    You’ll notice that rows 1, 2, 3 are related as are rows 4, 5 and rows 6, 7, 8.
    This is what we ultimately want to see given the results above.
    In the report, rows 1, 2, 3 from the results should roll into one row with the ScannedByTimeStamp from each row returned by the query populating the appropriate report time column based on the value of a column in the row.
    Col 1   Col 2   Taken Date  Date 1                  Date 2                
    Date 3
    Data    Data    3/12/2015  3/12/2015 7:22    3/12/2015 8:47   3/12/2015 9:27
    Data    Data    3/22/2015                               3/22/2015 7:27  
    Data    Data    4/12/2015
    We would appreciate any guidance.

    Hi Duane,
    The table and matrix data regions can display complex data relationships by including nested tables,matrices, lists, charts and gauges. Tables and matrices have a tabular layout and their data comes from a single dataset, built on a single data source. The
    key diference between tables and matrices is that tables can include only row groups, where as matrices have row groups and columns groups.
    All Code in this sample are downloadable from
    this URL
    create procedure spMultiple
    as
    begin
    declare @Mytable table ([Col 1] varchar(20),[Col 2] varchar(20),[Taken Date] varchar(20),[Date 1] varchar(20),[Date 2] varchar(20),[Date 3] varchar(20))
    Insert into @Mytable ([Col 1],[Col 2],[Taken Date],[Date 1],[Date 2],[Date 3])
    select * from
    Select 'Data' as [Col 1],'Data' as [Col 2],'3/12/2015' as [Taken Date],'3/12/2015 7:22' as [Date 1],'' as [Date 2],'' as [Date 3]
    union all
    Select 'Data' as [Col 1],'Data' as [Col 2],'3/12/2015' as [Taken Date],'' as [Date 1],'3/12/2015 8:47' as [Date 2],'' as [Date 3]
    union all
    Select 'Data' as [Col 1],'Data' as [Col 2],'3/12/2015' as [Taken Date],'' as [Date 1],'' as [Date 2],'3/12/2015 9:27' as [Date 3]
    union all
    select 'Data' as [Col 1],'Data' as [Col 2],'3/22/2015' as [Taken Date],'' as [Date 1],'3/22/2015 7:27' as [Date 2],'' as [Date 3]
    union all
    select 'Data' as [Col 1],'Data' as [Col 2],'3/22/2015' as [Taken Date],'' as [Date 1],'' as [Date 2],'' as [Date 3]
    union all
    select 'Data' as [Col 1],'Data' as [Col 2],'4/12/2015' as [Taken Date],'' as [Date 1],'' as [Date 2],'' as [Date 3]
    union all
    select 'Data' as [Col 1],'Data' as [Col 2],'4/12/2015' as [Taken Date],'' as [Date 1],'' as [Date 2],'' as [Date 3]
    union all
    select 'Data' as [Col 1],'Data' as [Col 2],'4/12/2015' as [Taken Date],'' as [Date 1],'' as [Date 2],'' as [Date 3]
    ) as temp;
    with Mytable2(
    [Col 1],
    [Col 2],
    [Taken Date],
    [Date],
    [NameDate]
    as
    SELECT
    [Col 1],
    [Col 2],
    [Taken Date],
    [Date],
    [NameDate]
    FROM
    (SELECT
    [Col 1],
    [Col 2],
    [Taken Date],
    [Date 1],
    [Date 2],
    [Date 3]
    FROM
    @MyTable) as p
    UNPIVOT
    [Date] FOR [NameDate] IN ([Date 1],[Date 2],[Date 3])
    )AS unpvt
    group by
    [Col 1],
    [Col 2],
    [Taken Date],
    [Date],
    [NameDate]
    Select * from Mytable2 t1 where [date]<>''
    end
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Ricardo Lacerda

  • How to combine .wmv files into one file???

    Hello Apple World,
    Can someone tell me a software that will allow me to combine ".wmv" files into one? I have several files that I need to combine then add music to. VERY simple with several software packages frow Windows pc's, but I'm struggling with this since getting my first mac! PLEASE help.

    Hi:
    How can I edit MPEG or convert DVD or MPEG to DV
    http://www.sjoki.uta.fi/%7Eshmhav/SVCDon_a_Macintosh.html#edit_convertMPEG
    Matti says it better than any of us:
    how/where you can join clips with Streamclip
    Also MPEG Streamclip guide explains it.
    MPEG Streamclip can join similar MPEG files: The joined files must have the same PIDs, the same start codes, and the same audio/video properties (that is, they must come from the same source or channel).
    Using "Convert to MPEG" before joining the files can be helpful, because it changes PIDs and start codes to a default value. The preferred method to join streams is to Copy one stream in MPEG Streamclip, open another stream and Paste it there. This method checks that the joined streams indeed are compatible. Another method is to put the MPEGs in the same folder, and rename them so that they sort as desired in list view. Then select them via MPEG Streamclip's "File/Open Files..." dialog box (Shift- or Command-click to select multiple MPEGs). Then choose "Edit/Fix Timecode Breaks". After this MPEG Streamclip should report the combined length of all MPEGs (check the Log Window if you want to know whether any timecode breaks were found). Then choose "File/Convert to MPEG... or /Save As..." to save them in a single file. If the video transition between two files looks bad, you can use the Cut command to improve it. You can join very different and incompatible MPEGs with this latter method so the end result is not guaranteed to work.
    MPEG Streamclip can also edit MPEG files. Just set In/Out points (with I/O keys), Cut unwanted material off and choose "File/Convert to MPEG...". You can also Cut/Copy selections to other parts of the same stream or open another compatible stream and Paste it there. Shift-dragging the playhead can also be used to define a selection. Option + arrow keys jump to the beginning/end or In/Out points. You can use the Trim-command to more closely see a part of the video before cutting, then choose Revert Trimming to see all material. JKL-keys can be used to enable fast forward or reverse playing. The scroll wheel works also; with the Option key it scrolls 1 second per click. See the manual for more details on how to jump in single frame, GOP, 1 second, 10 second or 1 minute chunks when searching a specific spot in the video.
    Editing and trimming can be accurate only if In and Out are both on keyframes because MPEG Streamclip edits to the GOP, not to the frame. For DVD and (XS)VCD the maximum GOP size is PAL 15 and NTSC 18 frames, so the editing accuracy can be up to about 0.6 seconds. You can advance to the previous or next keyframe (i.e. I-frame, the beginning of each GOP or Group Of Pictures) with the Up/Down arrow keys -- you can also use the Edit/Go to Keyframe command to see where the In and Out points really are when editing (the In point is included in the selection, the Out point is not included). Shift + Up/Down arrow keys allow fine-tuning the selection to the GOP.
    Sue

  • How to combine video clips into one video clip using FCPX

    I typed this into the search engine but could not come up with anything. How do you combine Video clips into one Video clip using FCPX? Thanks in advance.
    Gar

    The simple answer is to put the clips together in a project in the desired order and export (oops, the new word is share [YUK!]) a master file.
    But maybe you should say a little more about the clips to determine whether the answer I've given is relevant to yor situation.

  • How to combine multiple webservices into one WSDL file

    Gurus,
    I have 4 four webservices(ws1,ws2,ws3 & ws4) defined in XI. Normally in XI when we define webservice ,WSDL file will be generated for each interface. Now I have 4 related interfaces, so 4 WSDL files will generated. Suppose if I have 100 webservices then 100 WSDL files need to be generated & need to send to other party to consume our services, which is very tedious task & to track also. So is it possible to combine related webservices into one WSDL file? Your inputs will be highly appreciated.
    Regards,
    Santhosh

    Hi,
             Instead of trying to combine the interfaces, you can try to define your interface mapping with 4 sender interfaces with in one interface mapping . I think this may give you the result you are expecting.
                      If you want entire content to be in one interface , then, define single interface which can accomadate, all message ocntent of all 4 interfaces.Means your sender message to contain the 4 datatypes internally.
    Regards,
    Reyaz

  • Concatenate strings from more rows into one row.

    Hi,
    what's the name of that analytical function (or connect by) that
    would return strings from more rows as one row concatenated. i.e.:
    (I know this is possible using regular pipelined functions.)
    ROW1:   STR1
    ROW2:   STR2
    ROW3:   STR3
    select tadah().... from ...
    result:
    ROW1: STR1 STR2 STR3Thanks.

    Hi,
    Here's a basic example of SYS_CONNECT_BY_PATH.
    The query below produces one row of output per department, containing a list of the employees in that department, in alphabetioc order.
    WITH     got_rnum     AS
         SELECT     ename
         ,     deptno
         ,     ROW_NUMBER () OVER ( PARTITION BY  deptno
                                         ORDER BY          ename
                              ) AS rnum
         FROM     scott.emp
    --     WHERE     ...          -- Any filtering goes here
    SELECT     deptno
    ,     LTRIM ( SYS_CONNECT_BY_PATH ( ename
                                  , ','     -- Delimiter, must never occur in ename
               )          AS ename_list
    FROM     got_rnum
    WHERE     CONNECT_BY_ISLEAF     = 1
    START WITH     rnum          = 1
    CONNECT BY     rnum          = PRIOR rnum + 1
         AND     deptno          = PRIOR deptno
    ;Output:
    .   DEPTNO ENAME_LIST
            10 CLARK,KING,MILLER
            20 ADAMS,FORD,JONES,SCOTT,SMITH
            30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARDThe basic CONNECT BY query would produce one row per employee, for example:
    .   DEPTNO ENAME_LIST
            10 ,CLARK
            10 ,CLARK,KING
            10 ,CLARK,KING,MILLER
            20 ,ADAMS
            20 ,ADAMS,FORD
    ...The WHERE clause: <tt>WHERE CONNECT_BY_ISLEAF = 1</tt> means that we'll only see the last row for every department.
    SYS_CONNECT_BY_PATH (which is a row function, by the way, not an analytic fucntion) puts a delimiter (',' in the example above) before every item on the list, including the first one.
    The query above uses LTRIM to remove the delimiter at the very beginning.
    WM_COMCAT (or the equivalent user-defined STRAGG, which you can copy from AskTom) is much more convenient if order is not important.

  • How to combine movie clips into one?

    In one Aperture project I have 5 short (under 1 min) movie clips that I would like to combine into one "movie", and would like to know the quickest and easiest way to do this.  I am not interested in any editing other than combining the clips into one.  Thanks!

    In Aperture the only way to combine movie clips is to create a basic slideshow, but you will get better results (stabilization, effects, etc) in iMovie or Quicktime 7, if you have it.
    In Aperture:
    Create a slideshow with the "Classic" theme: Select the two video clips in the Browser and use:   File >New > Slideshow
    Set the Default Slideshow settings (Transitions, Text, background) as you like them.
    Arrange the clips in the Time Line in the order as you want them.
    Press the "Export" button in the upper right corner to export a new video. Reimport it to Aperture.
    Regards
    Léonie

  • How to Group Few Rows into One Rows In Query

    Dear All,
    I've use the "Group By" syntax in my query, but when the result display, it still show few rows instead of one row.
    Current Results
    item         Jan       Feb        Mar
    A              10          0           20
    A              10          0            0
    A               0           5            0
    B               0           0           10
    Desire Result
    item        Jan         Feb         Mar
    A             20           5           20
    B             0             0           10
    My query is:
    /*select from [dbo].[oinv] T0 */
    declare @customer varchar (200)
    /* where */
    set @customer = /* T0.Cardname */ '[%A]'
    /*select from [dbo].[inv1] T1 */
    declare @fromdate as datetime
    /* where */
    set @fromdate = /* T1.DOCDATE */ '[%1]'
    /*select from [dbo].[inv1] T2 */
    declare @tilldate as datetime
    /* where */
    set @tilldate = /* T1.DOCDATE */ '[%2]'
    SELECT inv1.ITEMCODE, oitm.itemname,
    CASE WHEN MONTH(INV1.DOCDATE) = 1 THEN SUM(QUANTITY) ELSE NULL END AS 'JAN',
    CASE WHEN MONTH(INV1.DOCDATE) = 2 THEN SUM(QUANTITY) ELSE NULL END AS 'FEB',
    CASE WHEN MONTH(INV1.DOCDATE) = 3 THEN SUM(QUANTITY) ELSE NULL END AS 'MAR',
    CASE WHEN MONTH(INV1.DOCDATE) = 4 THEN SUM(QUANTITY) ELSE NULL END AS 'APR',
    CASE WHEN MONTH(INV1.DOCDATE) = 5 THEN SUM(QUANTITY) ELSE NULL END AS 'MAY',
    CASE WHEN MONTH(INV1.DOCDATE) = 6 THEN SUM(QUANTITY) ELSE NULL END AS 'JUN',
    CASE WHEN MONTH(INV1.DOCDATE) = 7 THEN SUM(QUANTITY) ELSE NULL END AS 'JUL',
    CASE WHEN MONTH(INV1.DOCDATE) = 8 THEN SUM(QUANTITY) ELSE NULL END AS 'AUG',
    CASE WHEN MONTH(INV1.DOCDATE) = 9 THEN SUM(QUANTITY) ELSE NULL END AS 'SEPT',
    CASE WHEN MONTH(INV1.DOCDATE) = 10 THEN SUM(QUANTITY) ELSE NULL END AS 'OCT',
    CASE WHEN MONTH(INV1.DOCDATE) = 11 THEN SUM(QUANTITY) ELSE NULL END AS 'NOV',
    CASE WHEN MONTH(INV1.DOCDATE) = 12 THEN SUM(QUANTITY) ELSE NULL END AS 'DEC'
    FROM OINV inner join inv1 on oinv.DocEntry = inv1.DocEntry INNER JOIN OITM on inv1.itemcode = oitm.itemcode
    WHERE oinv.cardname =@customer AND inv1.DOCDATE >=@fromdate AND inv1.DOCDATE <=@tilldate
    GROUP BY inv1.ITEMCODE, oitm.itemname, inv1.docdate
    I've tried to write in "Select Syntax" too, but still get the same result. I'm really have no idea what's wrong with my query. Thanks for all your help!
    Cheers,
    Serene

    Hi Serene,
    in last query I forgot in subquery condition for customer (the sum was for all customers).
    Try this:
    SELECT distinct inv1.ITEMCODE, oitm.itemname,
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock) where  xx.docentry = x.docentry and xx.cardname = @customer and inv1.itemcode = x.itemcode and month(x.docdate ) = 1 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'JAN',
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock)  where  xx.docentry = x.docentry and xx.cardname = @customer and inv1.itemcode = x.itemcode and month(x.docdate ) = 2 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'FEB',
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock)  where  xx.docentry = x.docentry and xx.cardname = @customer and inv1.itemcode = x.itemcode and month(x.docdate ) = 3 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'MAR',
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock)  where xx.docentry = x.docentry and xx.cardname = @customer and  inv1.itemcode = x.itemcode and month(x.docdate ) = 4 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'APR',
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock)  where xx.docentry = x.docentry and xx.cardname = @customer and  inv1.itemcode = x.itemcode and month(x.docdate ) = 5 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'MAY',
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock)  where xx.docentry = x.docentry and xx.cardname = @customer and  inv1.itemcode = x.itemcode and month(x.docdate ) = 6 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'JUN',
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock)  where xx.docentry = x.docentry and xx.cardname = @customer and  inv1.itemcode = x.itemcode and month(x.docdate ) = 7 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'JUL',
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock)  where xx.docentry = x.docentry and xx.cardname = @customer and  inv1.itemcode = x.itemcode and month(x.docdate ) = 8 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'AUG',
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock)  where xx.docentry = x.docentry and xx.cardname = @customer and  inv1.itemcode = x.itemcode and month(x.docdate ) = 9 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'SEP',
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock)  where xx.docentry = x.docentry and xx.cardname = @customer and  inv1.itemcode = x.itemcode and month(x.docdate ) = 10 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'OCT',
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock)  where xx.docentry = x.docentry and xx.cardname = @customer and  inv1.itemcode = x.itemcode and month(x.docdate ) = 11 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'NOV',
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock)  where xx.docentry = x.docentry and xx.cardname = @customer and inv1.itemcode = x.itemcode and month(x.docdate ) = 12 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'DEC'
    FROM OINV
    inner join inv1 on oinv.DocEntry = inv1.DocEntry
    INNER JOIN OITM on inv1.itemcode = oitm.itemcode
    WHERE oinv.cardname =@customer and quantity > 0
    AND inv1.DOCDATE >=@fromdate AND inv1.DOCDATE <=@tilldate

  • How to combine several files into one?

    How to combine several pdf files into one?

    Combine Files is a feature of Acrobat Pro.  Because Reader Touch does not support the feature (yet), this is not the right forum for the question.
    Here's the Acrobat forum for Creating, Editing & Exporting PDFs.
    http://forums.adobe.com/community/acrobat/creating__editing_%26_exporting_pdfs
    You can ask questions and get help from Acrobat experts there.  Good luck!

  • How to Combine Time Aliases into One Time Dim in Presentation Table

    Hi,
    As per the requirement I have created 7 time aliases and created joins to the fact in physical layer and the same in the BMM as well. I guess I’m correct till this stage.
    However I want all the aliases to be combined into one time dim table so that only one time dimension will be available in Presentation layer Can I do it if yes what’s the process, now I’m showing all the time aliases in presentation which I don’t want to.
    Please suggest me to solve this.
    Thanks,
    SMA

    HI Arjun,
    Please look at Sample Sales rpd "D0 Time" table(BMM layer) it was coming from different physical alias tables based on that how the hierarchy was built
    Its not creating any attributes under the dimension so hoe to create the levelsRight click on hierarchy add Parent level and child level then pull the columns from your time dim to hierarchy
    thanks,
    Saichand.v

Maybe you are looking for

  • Use of synchronisation with the SUN DAO Pattern

    With reference to the design pattern Core J2EE Patterns Data Access Object: http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html I am writing a DAO package to handle access to multiple datasources at a record level (e.g. use

  • Av adapter not working with ipad 2, please advice

    I bought an av adapter 2012 release, is not working with my ipad 3g att ios version 4.3.5 i tried reset, changing the widescreen button multiple times no luck no video mirroring or sound. When i plug there is a msg displayed: accessory not supported.

  • Newbie to Aperture and I am a new Imac owner who switched from a PC

    I shoot with a Nikon D300 and I keep all of my photos on external hard drives. I perfer to keep my photos located on these drives. How do I move my photos into Apeture to work on my photos and then have them stored on my external hard drives. I use P

  • Disk Imaging problem

    We're using a PXI-8185 for an autonomous experiment. We would like to make a backup image of the disk with Norton Ghost so that if the disk crashes, we can get a duplicate disk running quickly. I've done this previously with the old Power Quest Disk

  • Accessing ribbon via vba ApplicationOptionsDialog

    hi, I am using microsoft access 2010 project (adp). I need to disable the file menu when I distribute the ade to clients. the backstage disable has no effect. my customized ribbon below. I only need to a way via vba to turn off the ApplicationOptions