Showing report data columns into two rows instead of one row using SSRS 2012

Hi All,
I have a ssrs report with 13 columns and I want to show those 13 columns data into two rows instead of showing in one row. please send me step by step process.
id     fullname     firstname      lastname        mailingaddress     billingaddress       
city       state       zipcode   
1       ABC                A                  C                  
    xyz                      xyz123                   york     
PA          12345    
 homephone     cellphone          workphone          company    
1234567890      4567890123     0123456789         ABC,Inc
id     fullname     firstname      lastname        mailingaddress     billingaddress        
city          state     zipcode   
2          XYZ               X                  Z                      
     abc                     abc123           lewisburg     
PA      54321    
 homephone     cellphone           workphone        company    
4567890123      0123456789     1234567890         xyz,Inc
id     fullname     firstname      lastname        mailingaddress     billingaddress        
city          state     zipcode   
3       BCD                  B                  D                  
123abc                  xyz123                leesburg       PA     
 54123    
 homephone     cellphone          workphone        company    
4567895623      0783456789     1238967890       Hey,Inc
Thanks in advance,
RH
sql

Do a right mouse click on the left, gray row marker => "Insert Row"=> "Inside Group
- Above or Below", then you get a second detail row.
Olaf Helper
[ Blog] [ Xing] [ MVP]

Similar Messages

  • Producedure givng two rows instead of one row

    Hi
    Please find below my procedure..when I execute this proc...displays two rows instead of one row. Please help me incase if I did mistake.
    CREATE PROCEDURE SP_CWCTravel_Cruise_Amenities_S(
            @Cruise_Line_Code varchar(2500) = NULL,
            @Ship_Code varchar(2500) = NULL,
            @Sail_Id varchar(100) = NULL,
            @Base_Price decimal(8, 2),
            @Category_Groups varchar(2500) = NULL,
            @Categories varchar(2500) = NULL,
            @Rate_Codes varchar(2500) = NULL,
            @Booking_Date VARCHAR( 10 ),
            @Sail_Start_Date VARCHAR( 10 )
    AS
    BEGIN
        SELECT  TOP 1 *
        FROM CWCTravel_Cruise_Amenities_Definition as cad
                                    JOIN CWCTravel_Cruise_Amenities_Definition_Date_Range AS caddr
                                    ON cad.id = caddr.Amenities_Definition_Id
        WHERE Cruise_Line_Code in (SELECT item FROM SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Cruise_Line_Code))
            AND (Min_Base_Price = 0 OR Min_Base_Price <= @Base_Price)
            AND (Max_Base_Price = 0 OR Max_Base_Price >= @Base_Price)
            AND (Ship_Code IS NULL OR Ship_Code = '' OR Ship_Code IN (SELECT item FROM SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Ship_Code)))
            AND (Sail_Id IS NULL OR Sail_Id = '' OR Sail_Id IN (SELECT item FROM SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Sail_Id))) 
            AND (Rate_Codes IS NULL OR Rate_Codes = '' OR ((SELECT COUNT(*) FROM
                                                                                       (SELECT Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Rate_Codes)) A,
                                                                                       (SELECT REPLACE(REPLACE(Item,'?', '_'), '*', '%') Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(Rate_Codes)) B
                                                                                        WHERE A.Item LIKE B.Item) > 0))
                                    AND (Category_Groups IS NULL OR Category_Groups = '' OR ((SELECT COUNT(*) FROM
                                                                                       (SELECT Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Category_Groups)) A,
                                                                                       (SELECT  Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(Category_Groups)) B
                                                                                        WHERE A.Item LIKE B.Item) > 0))
                    AND (Categories IS NULL OR Categories = '' OR ((SELECT COUNT(*) FROM
                                                                                       (SELECT Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Categories)) A,
                                                                                       (SELECT  Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(Categories)) B
                                                                                        WHERE A.Item LIKE B.Item) > 0))
                                    AND  (@Booking_Date is null or @Booking_Date=''
                                                                                                    OR (( caddr.from_date IS NULL OR caddr.from_date <= @Booking_Date ) AND ( caddr.to_date IS NULL OR caddr.to_date >= @Booking_Date )                                                                                   
                                                                                    AND  (( caddr.date_range_type IS NULL ) OR ( caddr.date_range_type = 'BOOK_DATE' ))) )
        union
        SELECT  TOP 1 *
        FROM CWCTravel_Cruise_Amenities_Definition as cad
                                    JOIN CWCTravel_Cruise_Amenities_Definition_Date_Range AS caddr
                                    ON cad.id = caddr.Amenities_Definition_Id
        WHERE Cruise_Line_Code in (SELECT item FROM SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Cruise_Line_Code))
            AND (Min_Base_Price = 0 OR Min_Base_Price <= @Base_Price)
            AND (Max_Base_Price = 0 OR Max_Base_Price >= @Base_Price)
            AND (Ship_Code IS NULL OR Ship_Code = '' OR Ship_Code IN (SELECT item FROM SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Ship_Code)))
            AND (Sail_Id IS NULL OR Sail_Id = '' OR Sail_Id IN (SELECT item FROM SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Sail_Id))) 
            AND (Rate_Codes IS NULL OR Rate_Codes = '' OR ((SELECT COUNT(*) FROM
                                                                                       (SELECT Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Rate_Codes)) A,
                                                                                       (SELECT REPLACE(REPLACE(Item,'?', '_'), '*', '%') Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(Rate_Codes)) B
                                                                                        WHERE A.Item LIKE B.Item) > 0))
                                    AND (Category_Groups IS NULL OR Category_Groups = '' OR ((SELECT COUNT(*) FROM
                                                                                       (SELECT Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Category_Groups)) A,
                                                                                       (SELECT  Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(Category_Groups)) B
                                                                                        WHERE A.Item LIKE B.Item) > 0))
                    AND (Categories IS NULL OR Categories = '' OR ((SELECT COUNT(*) FROM
                                                                                       (SELECT Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Categories)) A,
                                                                                       (SELECT  Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(Categories)) B
                                                                                        WHERE A.Item LIKE B.Item) > 0))
            AND  (@Sail_Start_Date is null or @Sail_Start_Date=''
                                                                                                    OR (( caddr.from_date IS NULL OR caddr.from_date <= @Sail_Start_Date ) AND ( caddr.to_date IS NULL OR caddr.to_date >= @Sail_Start_Date )                                                                                   
                                                                                    AND  (( caddr.date_range_type IS NULL ) OR ( caddr.date_range_type = 'TRAVEL_DATE' ))) )                                                                        
        ORDER BY Cruise_Line_Code DESC, Ship_Code DESC, Sail_Id DESC, Rate_Codes DESC, Category_Groups DESC, Categories DESC
    ENDWhile executing this SP
    I am getting the following results.
    2043 23-07-2010 AM 11:22:10 23-08-2011 PM 04:57:19 8 princess caribbeanPrincess 2043 20-08-2011 AM 12:00:00 30-11-2011 AM 12:00:00 BOOK_DATE
    2043 23-07-2010 AM 11:22:10 23-08-2011 PM 04:57:19 8 princess caribbeanPrincess 2043 01-10-2011 AM 12:00:00 30-11-2011 AM 12:00:00 TRAVEL_DATE
    I need only the first record.
    Thanks in adv
    Rekha

    871270 wrote:
    Hi
    Please find below my procedure..when I execute this proc...displays two rows instead of one row. Please help me incase if I did mistake.Seriously?
    You wrote a query against tables we've never seen, containing data we can't possibly have any idea about and you expect us to be able to help you?
    Please go discuss this with someone in your organization who understands the data model and have them explain to you how it is supposed to work.
    Put yourself in our situation (forum volunteers) ... if we threw some arbitrary code with no explanation as to what it does, what the data model looks like and what's supposed to be happening, do you think you'd be very successful ?

  • When i take a picture with my iphone camera it goes into two folders instead of one how do i stop this from happening

    well my old iphone broke ish so when i conected it to itunes everyphoto i had when on my computer as a folder
    so when i got my new iphone i sync it to the computer
    but now every time i take a photo it goes into two seperate folders
    on my old folder and my new one

    Looks like it is time for the young birds to leave the nest just a little.
    Family Sharing - Apple Support
    ÇÇÇ

  • Time of email shows in Date Column, Date is not showing on new emails

    Date is not showing in Date column. Only time is showing.
    I just migrated from OE - Old emails show the time & Date.

    If these are emails received today that is normal. Thunderbird assumes you know what day it is and only displays the time for messages received today. It will append the date to these messages at midnight tonight.

  • I want to load data parallely into two ods.

    i want to load data parallely into two ods.

    Hai ,
       As Question is not clear........
      U can do this by going in update tab in sechdule menu.
    Regards
    Suman

  • Report Data in to two alternate Unit of Measures

    Hi
    We Implemented "How to Report Data in to two alternate Unit of Measure". I have a question
    1 Could we maintain Two alternate Unit of Measures for one Base Unit of Measure?
    For example if Base unit is EA ( Each) we need to maintain this as CAR( Carton) and PAL ( Pallet).
    Thanks
    Naga

    Hi Naga,
    Are you talking about Qty Unit conversion. We can surely maintain CAR,EA,PAL and all. The Numerator and Denoms are maintained in T006. And accordingly the conversion happens.
    Apart from that you can have your own customized Qty conversion using Transaction 'RSUOM'.
    Lemme me know if this helps.
    -Bikas

  • How to drill date (column )into month in xcelsius

    Hi,
    I am fresher to Xcelsius. I need to know how to drill the date column into month, then further drilling down month to day.
    I have 2 columns
    Date                       Revenue
    1/1/2010                 452553
    2/2/2011                  97992
    3/5/2011                  23526
    4/3/2011                 63563
    If i click " 1/1/2011" date column, i need to see the corresponding month data in seperate chart( i need to get the detailed data).
    I need to know how the datas should be arranged in excel.
    Thanks in Advance
    Regards,
    Abirami

    Hi Abirami,
    To filter out date, you can use calendar component in Xcelsius. This article explains how to use the calendar component in an interactive way.
    http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/b05b0244-0453-2e10-b4b3-fab707baddaf
    Then with the help of an invisible combo box as explained in the article to could get just the selected month's data in bar chart.
    Hope this helps.
    Regards,
    Anju Saseendran

  • SQL*Plus two fetches for getting one row.

    Hi all.
    I have tested following script.
    alter session set events '10046 trace name context forever, level 12';
    select * from dual;And achieved such results (extract from .trc file).
    SQL*Plus: Release 11.2.0.1.0; (Oracle Version 10.2.0.4.0, 11.2.0.1.0)
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        2      0.00       0.00          0          0          0           1
    total        4      0.00       0.00          0          0          0           1SQL*Plus: Release 8.1.7.0.0; (Oracle Version 8.1.7.0.0)
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      2      0.00       0.00          0          0          0           0
    Fetch        2      0.00       0.00          0          1          4           1
    total        5      0.00       0.00          0          1          4           1Allround Automations PL/SQL Developer 8.0.4; (Oracle Version 10.2.0.4.0, 11.2.0.1.0)
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      0.00       0.00          0          0          0           1
    total        3      0.00       0.00          0          0          0           1Allround Automations PL/SQL Developer 8.0.4; (Oracle Version 8.1.7.0.0)
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      0.00       0.00          0          1          4           1
    total        3      0.00       0.00          0          1          4           11) I can't figure out why sqlplus does TWO fetches for getting ONE row (instead of pl/sql developer).
    8i raw trace
    PARSING IN CURSOR #1 len=31 dep=0 uid=0 oct=3 lid=0 tim=0 hv=3549852361 ad='4a0155c'
    select 'hello world' from dual
    END OF STMT
    PARSE #1:c=0,e=0,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=0
    BINDS #1:
    EXEC #1:c=0,e=0,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=0
    WAIT #1: nam='SQL*Net message to client' ela= 0 p1=1111838976 p2=1 p3=0
    FETCH #1:c=0,e=0,p=0,cr=1,cu=4,mis=0,r=1,dep=0,og=4,tim=0
    WAIT #1: nam='SQL*Net message from client' ela= 0 p1=1111838976 p2=1 p3=0
    FETCH #1:c=0,e=0,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=0,tim=0
    WAIT #1: nam='SQL*Net message to client' ela= 0 p1=1111838976 p2=1 p3=0
    WAIT #1: nam='SQL*Net message from client' ela= 0 p1=1111838976 p2=1 p3=0
    STAT #1 id=1 cnt=1 pid=0 pos=0 obj=195 op='TABLE ACCESS FULL DUAL '11g raw trace
    PARSING IN CURSOR #3 len=30 dep=0 uid=96 oct=3 lid=96 tim=1581355246985 hv=1158622143 ad='b8a1bcdc' sqlid='5h2yvx92hyaxz'
    select 'hello world' from dual
    END OF STMT
    PARSE #3:c=0,e=130,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,plh=1388734953,tim=1581355246984
    EXEC #3:c=0,e=40,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,plh=1388734953,tim=1581355247154
    WAIT #3: nam='SQL*Net message to client' ela= 7 driver id=1111838976 #bytes=1 p3=0 obj#=-1 tim=1581355247252
    FETCH #3:c=0,e=18,p=0,cr=0,cu=0,mis=0,r=1,dep=0,og=1,plh=1388734953,tim=1581355247324
    STAT #3 id=1 cnt=1 pid=0 pos=1 obj=0 op='FAST DUAL  (cr=0 pr=0 pw=0 time=0 us cost=2 size=0 card=1)'
    WAIT #3: nam='SQL*Net message from client' ela= 193 driver id=1111838976 #bytes=1 p3=0 obj#=-1 tim=1581355247735
    FETCH #3:c=0,e=2,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=0,plh=1388734953,tim=1581355247800
    WAIT #3: nam='SQL*Net message to client' ela= 5 driver id=1111838976 #bytes=1 p3=0 obj#=-1 tim=15813552478552) Is there any possibility to view data provided by each fetch?
    Thanks in advance!
    P.S.
    SQL> sho arraysize
    arraysize 15

    Thanks.
    I have tested two statements.
    select 'hello world' from dual where 1=1;
    select 'hello world' from dual where 1=0;When query returns no data, there is only one SQL*Net roundtrip (and one fetch)
    SQL> set autot on statistics
    SQL> select 'hello world' from dual where 1=1;
    'HELLOWORLD
    hello world
    Statistics
              0  recursive calls
              0  db block gets
              0  consistent gets
              0  physical reads
              0  redo size
            528  bytes sent via SQL*Net to client
            492  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processed
    SQL> select 'hello world' from dual where 1=0;
    no rows selected
    Statistics
              0  recursive calls
              0  db block gets
              0  consistent gets
              0  physical reads
              0  redo size
            329  bytes sent via SQL*Net to client
            481  bytes received via SQL*Net from client
              1  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              0  rows processedBut in both cases i found in client trace this sequence of bytes:
    ] nsprecv: 00 00 36 01 00 00 00 00  |..6.....|
    ] nsprecv: 00 00 00 00 00 00 00 00  |........|
    ] nsprecv: 00 00 90 19 43 13 00 00  |....C...|
    ] nsprecv: 00 00 00 00 00 00 00 00  |........|
    ] nsprecv: 00 00 00 00 00 00 00 00  |........|
    ] nsprecv: 00 00 00 00 00 00 00 00  |........|
    ] nsprecv: 00 00 00 00 00 00 00 00  |........|
    ] nsprecv: 00 00 00 00 00 00 00 00  |........|
    ] nsprecv: 00 00 00 00 00 00 00 00  |........|
    ] nsprecv: 00 00 00 00 00 00 00 00  |........|
    ] nsprecv: 00 00 19 4F 52 41 2D 30  |...ORA-0|
    ] nsprecv: 31 34 30 33 3A 20 6E 6F  |1403:.no|
    ] nsprecv: 20 64 61 74 61 20 66 6F  |.data.fo|
    ] nsprecv: 75 6E 64 0A              |und.    |In first case - it was in 2nd packet and in second case (query returns no data) - part of 1st packet.

  • Missing rows / output only one row in a Report after applying patchset 2

    Hi.
    We use Reports Builder for 10g R2. We had the problem with our AS 10g R2 on windows 2003, that some reports creates duplicate rows when it is a ASCII report (desformat = delimited), see Bug 3340546.
    Now we apply Patchset 2 on a local machine, to test the functionality. It fix the problem (look in metalink doc ID 398955.1 under "2.12 Oracle Reports Developer Bugs")-
    But now most csv reports creates only one row instead of multiple rows.
    We run reports on our local machine with OC4N and local started Form (via Forms Builder) to generate the reports (local started report server) from DevSuite).
    When we start the reports with desformat=delimited the txt-file has only the header row and one data row (instead of multiple ones).
    And when we generate the same report with desformat=delimiteddata it looks fine and generates all rows as expected.
    We found neither here in the forum or in metalink knowledge base nor on the internet.
    Have you any suggestions for us how to fix this problem?
    Using delimiteddata is now acceptable solution for us, because delimited is easier to use.
    Thanks for your help!

    Hey folks.
    We have solved the problem. :)
    We applied PatchSet2 for 10gR2. But we don´t know how the csv-report outputs only 1 data-row instead of several rows.
    Than we create a similar report (with the same sql-query) as a new one with the reports builder assistant.
    This one works pretty fine. So we looked for the attributes and see the "max. number datasets for each site" and it was in the new one set to 0 and in our old one set to 1.
    So we change this and ... the old one works pretty fine! :)
    So the problem is, that this attribute does not had any consequences in the old version. But since we update with PatchSet 2 it respect this attribute but we don´t "see" it.
    Hope this helps others.

  • Query result area on the first row instead of last row

    Hi BI experts,
    I want to display the result of  the BI query at the first row instead of last row.Could somebody help me how to accomplish this.
    I tried with the layout->move result area but could not be possible.
    I need your kind suggetion.
    Thanks.

    hi jyuoti,
    Further, open your query in query designer, look at the query property,  under the tab "rows/columns"
    change the result position of rows to "Below", you can see the preview there itself.
    This should solve your problem.
    Best Regards,
    *Assign points if you find the answer useful.

  • When typing an email, when I go to next line, it skips two lines instead of one line. How do I correct it?

    I was typing an email and when I would go to the next line, it will skip two lines instead of one line. How do I correct the problem?

    I am not sure I understand the problem. Could you include a screenshot of it right after it happens?
    If you need help to create a screenshot, please see [[How do I create a screenshot of my problem?]]
    Once you've done this, attach the saved screenshot file to your forum post by clicking the '''Browse...''' button below the ''Post your reply'' box. This will help us to visualize the problem.
    Thank you!

  • Splitting data up into two columns

    Apologies if this is covered previously ( i'm sure it probably is) i've imported .csv into numbers but the first cell contains two pieces of information separated by a space (TI NUMEROLOGY etc) how do I separate into two cells so I can sort data by the different identifers (TI = Title)
    IB 1859060196
    BI PAPERBACK
    AU SHINE
    BC VXFN
    CO UK
    PD 19990923
    NP 128
    RP 9.99
    RI 9.99
    RE 9.99
    PU CONNECTIONS BOOK PUBLISHING
    YP 1999
    TI NUMEROLOGY
    TI YOUR CHARACTER AND FUTURE REVEALED IN NUMBERS
    EA 9781859060193
    RF R
    SG 2
    GC M01
    DE A unique step-by-step visual approach to numerology
    DE characters and compatibility from names and birth dates.

    Hi Alan,
    Another thought. You can sort the data as it is. Click on Reorganize button on the ToolBar:
    To get:
    Every cell starting with TI and a space will come together, and sorted by whatever follows TI and a space.
    However, if it looks nicer to split the entries, use Badunit's formula.
    Alan wrote: "I also clicked on C2 and went to insert/fill/ but the options are greyed out o I can'r apply to all unless I do it manually... and it's a mahoosive file."
      To fill down, click on C2 then drag the white handle down. Or, select the rows that you want to fill before Insert > Fill (Numbers needs to know how far to fill).
    Ian.

  • Two rows instead of one in the database when form with 2 data blocks.

    Hi All,
    I have created a form having 2 data blocks
    data block one to populate table A
    data block two to populate table B .
    now when i save the data after pressing the save option ....i find 2 records instead of one in the database table A and Table B.
    it should have been just one per table ....can some one suggest pls
    Sunny

    ok : step by step :
    do you have a trigger created named "ON-INSERT" on
    the block?Many thanks for your support....
    I do not have an ON-insert trigger.....
    I will explain my scenerio.....
    I have 2 data blocks one-below the other in the form
    accessing 2 different tables....
    now on the canvas of this form I have added a
    button....and on that button i have written a trigger
    'when-button-pressed' Trigger....
    it takes the data from the various text_items of the
    form and inserts them into their corrosponding
    tables....and I have added 'COMMIT' at the end this
    trigger
    so when I press this button ....the data 2 records
    get inserted into the 2 tables instead of one each..
    TIA
    Sunnythe above form looks something like this.....
    -------------------------------------------------------------------------------------------------------|
    |------------------------------------------------------------------------------------------------------|
    | |
    | ---data_block1------------------------------------------------------ |
    | | | |
    | | some data entry here for emp1 table | |
    | |__________________________________________ | |
    | |
    | |
    | |
    | ---data_block2------------------------------------------------------ |
    | | | |
    | | some data entry here for dept1 table | |
    | |__________________________________________ | |
    | |
    | button1 |
    |-------------------------------------------------------------------------------------------------------

  • Webi Report Data compare between two columns

    There is two different queries in Webi Report BI 4.1
    Query 1 - Name_1 == 100 records
    Query 2 - Name_2 == 75 records
    On the report need to compare the data between Name_1 and Name_2.
    Need report level flag as a second column
    name_1 = name_2 = Y
    name_1 <> name_2 = N
    One the report there is only two columns Name_1 Flag(Y/N)
    1. If statement is not working at all in this scenario
    2. Merge dimension is not useful since I need to treat these columns separately on the report.

    Hi Suri,
    As the objects belong to two different queries, the comparison might not work as they are not merged and incompatible.
    You can try creating a seperate query and can use subquery in it.
    For example:
    SELECT NAME_1 FROM QUERY_1
    WHERE
    NAME_1 NOT IN (SELECT NAME_1 FROM QUERY_2)
    This will display the names which are not common.
    Hope it will help.
    Regards,
    Yuvraj

  • Split the column into two based on conditions

    Hello,
    I have 2 tables Country and Continent.
    Continent has the data like this
    ID               Name
    1               Asia
    2              Africa
    3              North America
    4             South America
    Country has 
    ID                Name                 ContinentID            Population
    1                  China                  1                                 2000
    2                  India                   1                                 1500
    3                  Ethiopia              2                                 7500
    4                  United States       3                                5000
    I need the count of countries for each continent  break into two columns based on the population. One column showing the count of countries with population <= 2000 and the other column should show the count of countries with population >2000
    How can I achieve this?
    Please help.
    Thank you

    Here you go:
    DECLARE @continent TABLE (ID INT, Name VARCHAR(30))
    INSERT INTO @continent (ID, Name) VALUES (1, 'Asia' ),(2, 'Africa' ),(3, 'North America'),(4, 'South America')
    DECLARE @country TABLE (ID INT, Name VARCHAR(30), ContinentID INT, Population INT)
    INSERT INTO @country (ID, Name, ContinentID, Population) VALUES (1, 'China', 1, 2000),(2, 'India', 1, 1500),(3, 'Ethiopia', 2, 7500),(4, 'United States', 3, 5000)
    SELECT COUNT(*), ct.name
    FROM @country c
    INNER JOIN @continent ct
    ON c.ContinentID = ct.ID
    GROUP BY ct.name
    and for the high/low:
    DECLARE @continent TABLE (ID INT, Name VARCHAR(30))
    INSERT INTO @continent (ID, Name) VALUES (1, 'Asia' ),(2, 'Africa' ),(3, 'North America'),(4, 'South America')
    DECLARE @country TABLE (ID INT, Name VARCHAR(30), ContinentID INT, Population INT)
    INSERT INTO @country (ID, Name, ContinentID, Population) VALUES (1, 'China', 1, 2000),(2, 'India', 1, 1500),(3, 'Ethiopia', 2, 7500),(4, 'United States', 3, 5000)
    ;WITH popRank AS (
    SELECT ROW_NUMBER() OVER (PARTITION BY ct.ID ORDER BY POPULATION DESC) AS row, ct.name AS continentName, c.name AS countryName, c.population, c.ContinentID
    FROM @country c
    INNER JOIN @continent ct
    ON c.ContinentID = ct.ID
    SELECT r.countryName AS biggestPopCountry, r.population as biggestPopCount, r1.countryName AS lowestPopCountry, r1.population as lowestPopCount
    FROM popRank r
    INNER JOIN popRank r1
    ON r.ContinentID = r1.ContinentID
    AND r1.row = (SELECT MAX(row) FROM popRank WHERE ContinentID = r.ContinentID)
    AND r.row = 1

Maybe you are looking for