Need sql query to solve the problem?

Hi,
My table contains data which is mentioned below:
Region
Country
DeviceType
Brand
ModelExt
AttributeGroup
AttributeType
AttributeValue
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
Input Key name on control panel_key order
Asdfg.1.1
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
Input Key name on control panel_key order
Input.TV
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
Input key Name on Display_key Order
ASDFG.1.in
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
Input key Name on Display_key Order
Input.Tv.IN
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
Input key Name on Display_key Order
RTYU.1
And i need O/p like
Region
Country
DeviceType
Brand
ModelExt
AttributeGroup
Input Key name on control panel_key order
Input key Name on Display_key Order
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
Asdfg.1.1
ASDFG.1.in
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
Input.TV
Input.Tv.IN
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
RTYU.1
Please help. Req. is urgent.
Regards,
Puneeth

You can use the CASE expression to pivot the AttributeType column.
Examples for CASE expression usage:
http://www.sqlusa.com/bestpractices/training/scripts/casefunction/
A second possibility is the PIVOT operator:
http://technet.microsoft.com/en-us/library/ms177410(v=sql.105).aspx
Instead of the COUNT or SUM operators, use MIN or MAX operators.
Kalman Toth Database & OLAP Architect
SQL Server 2014 Database Design
New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

Similar Messages

  • Need Sql Query that Suppress the repeating rows.

    Hi Sir,
    I have below data set.
    DeptID  Sum(SAL) Avg(Sal)
      10      1300      1300
      10      2450      1300
      10      5000      1300
      20      800        800
      20      1100      800
      20      2975      800
      20      3000      800
      30      800        800
      30      1100      800
      30      2975      800
      40      3000      800
      40      4000      900
    I Need  SQL query that can remove the duplicate or suppress.Just like below data set.
    Output:
    DeptID  Sum(SAL) Avg(Sal)
      10      1300      1300
                2450      1300
                5000      1300
      20       800        800
                1100      800
                2975      800
                3000      800
                800        800
      30      1100      800
                2975      800
      40      3000      800
               4000      900
    Could you please help me on this..

    Your requiremnt is more of a reporting request which should not be handled in SQL. For example in SQL Plus you can use the BREAK command
    SQL> break on deptno
    SQL> select deptno, ename from emp order by deptno;
        DEPTNO ENAME
            10 KING
               CLARK
            20 JONES
               SCOTT
               SMITH
               ADAMS
            30 TURNER
               MARTIN
               WARD
               ALLEN
               BLAKE
    11 rows selected.
    SQL>
    But if you still wish to do it in SQL you can use ROW_NUMBER analytic function and achieve it like this
    select decode(rno, 1, deptno) deptno
         , ename
      from (
              select row_number() over(partition by deptno order by ename) rno
                   , deptno
                   , ename
                from emp

  • Need SQL query to get the result.

    Region
    Month
    Trx Type
    Resolution Summary
    AMERICAS
    May-13
    Adjustments
    Correct
    EMEA
    May-13
    Adjustments
    Incorrect
    AMERICAS
    May-13
    Credit Memo
    Incorrect
    EMEA
    May-13
    Invoice
    Correct
    AMERICAS
    May-13
    Credit Memo
    Correct
    OFD
    May-13
    Adjustments
    Correct
    AMERICAS
    May-13
    Invoice
    Incorrect
    LAD
    May-13
    Adjustments
    Correct
    LAD
    May-13
    Adjustments
    Correct
    OFD
    May-13
    Adjustments
    Correct
    Above is my Table and find below the required result.Similarly for other regions as well. Can anyone help me with the SQL Query?
    Region
    Resolution Summary
    Adjustment
    Credit Memo
    Invoice
    Grand Total
    AMERICAS
    Correct
    1
    1
    2
    Incorrect
    0
    1
    1
    2

    Like this?
    SQL> select * from transaction_audit;
    REGION   MTH    TRX_TYPE    RESOLUTIO
    AMERICAS may-13 ADJUSTMENTS CORRECT
    EMEA     may-13 ADJUSTMENTS INCORRECT
    AMERICAS may-13 CREDIT MEMO INCORRECT
    EMEA     may-13 INVOICE     CORRECT
    AMERICAS may-13 CREDIT MEMO CORRECT
    OFD      may-13 ADJUSTMENTS CORRECT
    AMERICAS may-13 INVOICE     INCORRECT
    LAD      may-13 ADJUSTMENTS CORRECT
    LAD      may-13 ADJUSTMENTS CORRECT
    OFD      may-13 ADJUSTMENTS CORRECT
    10 rows selected.
    SQL> select region
      2       , resolution_summary
      3       , count(decode(trx_type, 'ADJUSTMENTS', trx_type)) adjustments
      4       , count(decode(trx_type, 'CREDIT MEMO', trx_type)) credit_memo
      5       , count(decode(trx_type, 'INVOICE'    , trx_type)) invoice
      6    from transaction_audit
      7   group
      8      by region
      9       , resolution_summary
    10   order
    11      by region
    12       , resolution_summary
    13  /
    REGION   RESOLUTIO ADJUSTMENTS CREDIT_MEMO    INVOICE
    AMERICAS CORRECT             1           1          0
    AMERICAS INCORRECT           0           1          1
    EMEA     CORRECT             0           0          1
    EMEA     INCORRECT           1           0          0
    LAD      CORRECT             2           0          0
    OFD      CORRECT             2           0          0
    6 rows selected.
    SQL>

  • Sql query to indetify the identical data

    Hi
    I would like to know the query to identify the identical data in same table.
    Example: I have table called 'AA" having same data for load_ctry i.e. 'MY' and 'HK' ,I need sql query to indetify the identical data for above countries in that table.
    Thanks
    MR

    Hi,
    Table called "AA" with columns col1,col2,col3,load_ctry with following sample date
    col1 col2 col3 load_ctry
    3 bg xx TH
    4 op xc TH
    3 bg xx MY
    4 op xc MY
    3 vb nb MY
    When query ,if data is identical for both countries ,no data to fecth or data identical .If data is differ ,it will return the mismatching data becuase we are using same table for both countries .
    Thanks
    MR

  • Help needed, M getting this message sandbox environment error no test user account, when downloading any application from iTunes, friend told me to sign out and sign in iTunes it might solve the problem but instead I cannot login I to my itune account.

    Help needed,
    I am getting this message sandbox environment error no test user account, when downloading any application from iTunes, friend told me to sign out and sign in iTunes it might solve the problem , and i triyed it but still  I cannot login I to my itune account. Same message keeping. Popping up,  this problem started supricly today.

    Take a look at the instructions here.
    http://www.technogal.net/2012/03/this-is-not-test-user-account-please.html

  • I have a 17 inch Mac book, after migrate to Lion, I take 25 seconds to shutdown. all progams are closed. any reason??   Need I to install a native Lion OS to solve the problem?   Regards,   José A. Pereira

    I have a 17 inch Mac book, after migrate to Lion, I take 25 seconds to shutdown. all progams are closed. any reason??
    Need I to install a native Lion OS to solve the problem?
    Regards,
    José A. Pereira

    Hi, Processor 2.66 Ghz Intel core i7, memory 8Gb 1067 Mhz DDR3.
    on shut down a White screen occur with a star flashing during more or less 25 seconds. before update to Lion, 3 or 4 seconds to shutdown. no more app installed or removed. it stills the same usage.
    I will be greatful if you can help me.
    Regards,
    José A. Pereira

  • I need a query that returns the average amount of characters for a text colum in MS SQL.

    I need a query that returns the average amount of characters
    for a text colum in MS SQL.
    Could someone show me how?

    Sorted, i need the
    DATALENGTH
    function

  • Need guidance to solve the problem.

    my internal hard drive is not showing up on mac. need guidance to solve the problem. thanks

    Hi,
    First make the finder the Front app.
    The Finder Menu > Preferences > General Section should have the Hard Drive item ticked to show the Hard Drive on the Desktop.
    The Name of the drive should not have a . at the beginng  as in .Mactinosh HD as this will make te file Invisible.
    There are also other characters that cause this.
    If you go to the Finder > Go Menu and select My Computer it should have opened a window displaying the Volumes ( Hard Drives and storage devices) that are connected.
    10:17 PM      Sunday; April 14, 2013
      iMac 2.5Ghz 5i 2011 (Mountain Lion 10.8.3)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • My AppStore can not download app. He said need to fill in credit card. But I got no credit card. And how I fill in? Please solve the problem. Thank you.

    My AppStore can not download app. He said need to fill in credit card. But I got no credit card. And how I fill in? Please solve the problem. Thank you.
    <Email Edited by Host>

    Hi Steve,
    If you don't have a credit card for the billing information you may be able to use a gift card or another form of payment.
    Please check out this article for details.
    Why can’t I select None when I edit my Apple ID payment information? - Apple Support
    Best,
    Nubz

  • My MacBook Air won't stay off. I turn it off and it will wait anywhere from a few seconds to a few hours and turn itself back on. You can see how that can get annoying and I can't seem to solve the problem.

    I turn it off and it will wait anywhere from a few seconds to a few hours and turn itself back on. You can see how that can get annoying and I can't seem to solve the problem.

    There's a slight chance this might help:
    Intel-based Macs: Resetting the System Management Controller (SMC)
    Otherwise it needs to be repaired.

  • HT1459 Serial number is faded and too small to read. Itunes will not recognize my IPod Classic. How can I delete the current iPod software and reinstall it to see if this would solve the problem?

    I recently upgraded my Itunes softeware, now itunes will not recognize my IPod Classic. If I delete the current IPod software and reinstall it, would this solve the problem, and if so, I'll need step by step instruction.

    Yep.
    Take a look here:
    http://www.snsforums.com/index.php?showtopic=235
    It appears that SANmp is indeed the most likely source of your problem.

  • Why is the sound of my new ipad cutting out intermittently and what does Apple recommend to solve the problem in lieu of any updates?

    Why is the sound of my new ipad cutting out intermittently and what does Apple recommend to solve the problem in lieu of any updates? All of a sudden without changing any settings, the audio on my NEW ipad cuts in and out on applications/ games, keypad noise and lock sounds. The rocker button only seems to work while the sound is intermittently being heard before, after a few seconds of noise not doing anything when sound goes off.
    This is highly frustrating as I've noticed others posting about such issues as far back as April. Anybody had the same thing happen to them? Is this likely software (ios6) or hardware issue? What are the solutions Apple???

    Apple has no physical stores of their own in Dubai, so unless you mean that you purchased from the online Apple Store for the UAE, you purchased from a dealer, who may or may not have been authorized. You can check the expiration date of the warranty on your iPad yourself by entering in the serial number here:
    https://selfsolve.apple.com/agreementWarrantyDynamic.do
    If it does indeed show the warranty has expired, then what you need to do from here will depend on who you purchased the iPad from and when you really did purchase it. Perhaps you actually purchased it in August and are just misremembering? Check your receipt. If you confirm that you did purchase within the last calendar year, tell us exactly where you got it and we can probably offer advice.
    Regards.

  • I cannot shut dow my MacBook Pro using the apple icon (as it was suppose to be), actually I have to press and hold the on/off buttom. I have taken twice for Mac dealer and they did not solve the problem. What must I do?

    I cannot shut dow my MacBook Pro using the apple icon (as it was suppose to be), actually I have to press and hold the on/off buttom. I have taken twice for Mac dealer and they did not solve the problem. What must I do? I would to remark that I have installed 2 antivirus and uninstalled one of them. Since then I have facing this troublesome issue. Thanks

    Uninstall the other AV software. They are not needed. All they do is cause trouble like you are having now.
    If you have been forcing the Mac to shut down with the power switch you may nave corrupted your disk. You should repair it with disk Utilty to remove any corruption the shutdwons may have cased.
    Allan

  • How should i solve the problem for the exception.

    <b>Web is below:</b>
    Error when processing your request
    <b>What has happened?</b>
    The URL http://xxxxxxx.xxxxx:xxxxxx/sap/bc/bsp/sap/xxxxxxx/result.htm was not called due to an error.
    <b>Note</b>
    The following error text was processed in the system D50 : The current application triggered a termination with a short dump.
    The error occurred on the application server sapcidev01_D50_00 and in the work process 1 .
    The termination type was: RABAX_STATE The ABAP call stack was:
    Form: DIALOG_CHECK of program CL_IMC_MODE===================CP
    Form: PREPARE_MODE of program CL_IMC_MODE===================CP
    Form: GET_MODE_BY_NAME of program CL_IMC_MODE===================CP
    Form: SEND_COMMAND of program CL_DV_IMC_CLIENT==============CP
    Form: PROCESS_COMMAND of program CL_DV_SDV=====================CP
    Form: DISP_DOC of program CL_DV_SDV=====================CP
    Form: DISP_AO_DOC of program CL_DV_SDV_AO==================CP
    Form: DISP_AO_DOCS of program CL_DV_SDV_AO==================CP
    Function: ALINK_DISPLAY_IMC of program SAPLALINK_DISPLAY_DOCUMENT
    Function: ARCHIVOBJECT_DISPLAY of program SAPLOPTA
    <b>What can I do?</b>
    If the termination type was RABAX_STATE, then you can find more information on the cause of the termination in the system D50 in transaction ST22.
    If the termination type was ABORT_MESSAGE_STATE, then you can find more information on the cause of the termination on the application server sapcidev01_D50_00 in transaction SM21.
    If the termination type was ERROR_MESSAGE_STATE, then you can search for more information in the trace file for the work process 1 in transaction ST11 on the application server sapcidev01_D50_00 . In some situations, you may also need to analyze the trace files of other work processes.
    If you do not yet have a user ID, contact your system administrator.
    Error code: ICF-IE-http -c: 151 -u: 117846 -l: E -s: D50 -i: sapcidev01_D50_00 -w: 1 -d: 20070320 -t: 062938 -v: RABAX_STATE -e: MESSAGE_TYPE_X
    HTTP 500 - Internal Server Error
    Your SAP Internet Communication Framework Team
    <b>Run ST22 and information is below:</b>
    Source Code Extract
    Line SourceCde
    1 METHOD DIALOG_CHECK.
    2 DATA: GUI_FLAG TYPE SY-BATCH.
    3
    4 * IMC NUR in Online-Modus ? (kein Batch und dunkle Batch-Input-Betrieb)
    5 IF GUI_IS_ON IS INITIAL.
    6 CALL FUNCTION 'RFC_IS_GUI_ON'
    7 EXPORTING
    8 LOGIN_CHECK = ' '
    9 IMPORTING
    10 ON = GUI_FLAG.
    11
    12 IF GUI_FLAG <> 'Y'.
    13 IF RABAX IS INITIAL.
    14 CLEAR EXISTS.
    15 ELSE.
    >>>>> MESSAGE X005(IMC).
    17 ENDIF.
    18 ELSE.
    19 GUI_IS_ON = 'Y'.
    20 EXISTS = 'X'.
    21 ENDIF.
    22 ELSE.
    23 EXISTS = 'X'.
    24 ENDIF.
    25
    26 ENDMETHOD.
    i can access the other bsp web.but this bsp application raises the exception. Who can help solve the problem?
    I appreciate your help.

    Is it SAP BSP application or custom?
    If its custom,check whether you are using any MESSAGE statements. Handle all the Exceptions from Class/Methods/Function module to avoid the Dump.
    Raja T

  • HT3910 I face problems with the Nvidia 8800 GS on my iMac 24'' 3.06Ghz intel core duo. OS 10.06.08. What can I do to solve the problem and if you recommend upgrade to mountain Lion

    I  face problems with the Nvidia 8800 GS on my iMac 24'' 3.06Ghz intel core duo. OS 10.06.08. What can I do to solve the problem and if you recommend upgrade to mountain Lion

    If you want to sync it to the iPad from that Mac, you need to upgrade it to at least 10.5.8.
    If you want to copy the music to another Mac, you don't. Move the iTunes folder of the item in the Finder's sidebar over as you would any other folder. If you put it somewhere other than the Music folder, launch iTunes with the Option key held down and point it to that location.
    (61713)

Maybe you are looking for

  • Exchange 2003 users are unable to send attachments larger then 8 MB to Exchange 2010 users on the same LAN

    I am migrating from Exchange 2003 to Exchange 2010. Users who are still on Exchange 2003 cannot send attachments any larger than around 8MB to Exchange 2010 users on the same LAN. Users on Exchange 2010 can send large attachments to fellow Exchange 2

  • Resizing labview window that has been converted

    I just would if it is possible to resize a labview window once it has been converted to a different version. I have labview 7.1 and converted to 6.1 and I am trying to resize the window but it doesn't let me. Is there another way around this?

  • SSIS Package configuration.

    The SSIS packages is developed using BIDS 2008 and Database SQL Server 2008 R2.The package was developed in local box/Developement box and since the connection string is pointing to local box , it works fine and data got loaded into the target tables

  • AxAcroPDF Limitations?

    I am using AxAcroPDF Activex object in a project I am working on and am finding some limitations.  One is the ability to rotate the images through code and disabling the right click menu. There is access to an execCommand method but no documentation

  • Distortion correction?

    Hi folks I am a new lightroom user, and I have been reading tutorials and guides for the last couple of days. As far as I can tell, Lightroom does not have the ability to correct barrel distortions (I have version 2.6). I have read about PTLens, but