SET UPDATE CASE WHEN HAVING GROUP BY all in one

I'm a little stuck with the code below that doesn't work. 
Basically in my table i return 3 rows per Name and they should all have the same location too, e.g. 3 Davids and 3 USA.  But sometimes I might have 3 Davids and 2 USA and 1 EU - so in this case I need to update a new column called SplitValue
and enter something like 1 or 0 depending on whether the name has 3 locations that are the same, just so we can report on it.
WITH cte AS (
SELECT name, location,
CASE WHEN [Location] < 2
THEN 'split'
ELSE 'NO Split'
END AS [SplitValue]
FROM [dbo].[Names]
GROUP BY name, location HAVING COUNT(location) < 2
UPDATE [dbo].[Names]
SET [Split] = cte.[splitvalue]

You're almost there.  Try this.
-- SETTING UP SOME TEST DATA TO MIMIC YOUR SOURCE DATA
DECLARE @Names TABLE (name varchar(30), location varchar(30), split varchar(10))
INSERT @Names (name, location) VALUES
('David', 'USA'), ('David', 'USA'), ('David', 'USA'),
('Bob', 'USA'), ('Bob', 'USA'), ('Bob', 'EU'),
('Jane', 'AUS'), ('Jane', 'USA'), ('Jane', 'EU'),
('Alex', 'EU'), ('Alex', 'EU'), ('Alex', 'EU')
;WITH NamesLocationGroups AS
SELECT name
,location
,CASE WHEN COUNT(*) < 2 THEN 'split'
ELSE 'NO Split'
END as splitvalue
FROM @Names
GROUP BY name
,location
UPDATE A SET A.split = B.splitvalue
FROM @Names A
JOIN NamesLocationGroups B
ON A.name = B.name
AND A.location = B.location
SELECT *
FROM @Names
Results will look like this:
name                           location                      
split
David                          USA                           
NO Split
David                          USA                           
NO Split
David                          USA                           
NO Split
Bob                            USA                           
NO Split
Bob                            USA                           
NO Split
Bob                            EU                            
split
Jane                           AUS                           
split
Jane                           USA                           
split
Jane                           EU                            
split
Alex                           EU                            
NO Split
Alex                           EU                            
NO Split
Alex                           EU                            
NO Split

Similar Messages

  • Error when use"select case when sum() group by"

    SELECT REGION_CODE
    ,REGION_DESC
    ,CASE WHEN SUM(UP_SMS_TIMES) BETWEEN T2.SMS_MIN AND T2.SMS_MAX THEN T2.SMS_LVL_CODE END
    FROM PMID.TB_MID_PAR_EXT_USER_MON T1, PCDE.TB_CDE_SMS_LVL T2
    WHERE DEAL_DATE='200811'
    GROUP BY REGION_CODE, REGION_DESC
    {color:#ff0000}error:ORA-00979: not a GROUP BY expression
    {color}{color:#000000}How can i fix the error,Thanks{color}

    -- CREATE TABLE TB_MID_PAR_EXT_USER_MO
    create table TB_MID_PAR_EXT_USER_MON
    DEAL_DATE CHAR(6),
    REGION_CODE CHAR(2),
    REGION_DESC VARCHAR2(20),
    UP_SMS_TIMES NUMBER(14) default 0,
    --INSERT SAMPLE DATA TO TB_MID_PAR_EXT_USER_MO
    insert into TB_MID_PAR_EXT_USER_MON(DEAL_DATE,REGION_CODE,REGION_DESC,UP_SMS_TIMES)
    VALUES('200812','BJ','BEIJING'11)
    insert into TB_MID_PAR_EXT_USER_MON(DEAL_DATE,REGION_CODE,REGION_DESC,UP_SMS_TIMES)
    VALUES('200812','SH','SHANGHAI',7)
    insert into TB_MID_PAR_EXT_USER_MON(DEAL_DATE,REGION_CODE,REGION_DESC,UP_SMS_TIMES)
    VALUES('200812','SH','SHANGHAI',9)
    insert into TB_MID_PAR_EXT_USER_MON(DEAL_DATE,REGION_CODE,REGION_DESC,UP_SMS_TIMES)
    VALUES('200812','BJ','BEIJING',10)
    insert into TB_MID_PAR_EXT_USER_MON(DEAL_DATE,REGION_CODE,REGION_DESC,UP_SMS_TIMES)
    VALUES('200812','BJ','BEIJING',5)
    insert into TB_MID_PAR_EXT_USER_MON(DEAL_DATE,REGION_CODE,REGION_DESC,UP_SMS_TIMES)
    VALUES('200812','BJ','BEIJING',19)
    ---- CREATE TABLE TB_CDE_SMS_LVL
    create table TB_CDE_SMS_LVL
    SMS_LVL_CODE INTEGER,
    SMS_LVL_DESC VARCHAR2(20),
    SMS_MIN NUMBER(14,2),
    SMS_MAX NUMBER(14,2)
    --INSERT SAMPLE DATA TO TB_CDE_SMS_LVL
    INSERT INTO TB_CDE_SMS_LVL(SMS_LVL_CODE,SMS_LVL_DESC,SMS_MIN,SMS_MAX)
    VALUES(1,'0 ITEM',-1.00,0.00)
    INSERT INTO TB_CDE_SMS_LVL(SMS_LVL_CODE,SMS_LVL_DESC,SMS_MIN,SMS_MAX)
    VALUES(2,'0-20 ITEM',0.00,20.00)
    INSERT INTO TB_CDE_SMS_LVL(SMS_LVL_CODE,SMS_LVL_DESC,SMS_MIN,SMS_MAX)
    VALUES(3,'20-40 ITEM',20.00,40.00)
    INSERT INTO TB_CDE_SMS_LVL(SMS_LVL_CODE,SMS_LVL_DESC,SMS_MIN,SMS_MAX)
    VALUES(4,'40- ITEM',40.00,9999999.00)
    --NOW,LET'S EXEC THE FOLLOWING STATEMENT
    SELECT REGION_CODE,REGION_DESC
    ,MAX(CASE WHEN SUM(UP_SMS_TIMES) BETWEEN T2.SMS_MIN AND T2.SMS_MAX THEN T2.SMS_LVL_CODE END) AS SMS_LVL
    FROM PMID.TB_MID_PAR_EXT_USER_MON T1,PCDE.TB_CDE_SMS_LVL T2
    WHERE DEAL_DATE='200811' AND UP_SMS_TIMES>0
    GROUP BY REGION_CODE, REGION_DESC
    --MY REQUIRED RESULT IS
    REGION_CODE REGION_DESC SMS_LVL
    SH SHANGHAI 2
    BJ BEIJING 4
    Thanks you!

  • TS1468 If all tracks on an album are written by one artist, but have other supporting artists, can I group them all as one album under the original artist without having to group them as a compilation and being called "Various Artists"?

    I'm pretty sure I've tried all the suggestions I've found, but I can't seem to find a satisfactory option.
    I'll use a CD I just bought as an example.  I just bought "The Best of Sergio Mendes", all songs are written by Sergio Mendes, but some include Brasil '66.  iTunes thinks this album is a compilation, but I really just want to group it all as Sergio Mendes rather than Various Artists, but I still want to have the information about which songs include Brasil '66.  For some reason the tab "Sorting" does absolutely nothing, but it seems like the idea behind it would be really useful if it actually worked...  Is there a way of doing this or will I have to settle with a more confusing or less informative option?  I feel like this must be possible, or else it's a pretty big flaw for me as I have a fair few albums this would apply to.
    Thanks in advance for any help.

    Indeed, generally all you need to do is fill in an appropriate Album Artist. For more details see my article on Grouping Tracks Into Albums, in particular the topic One album, too many covers.
    Don't try to use sort fields to merge different things together as it quickly goes wrong. These should be used consistently to make all things with one value sort as if they had a different one, e.g. Bowie, David to make David Bowie sort under B.
    tt2

  • HT1296 when syncing I have changed the contacts on my pc and then used the advance setting to replace on my phone and all the ones I changed come back to both the pc and the phone.  any help

    I have just installed ms outlook 2010 and am trying to sync my contacts and calendars and it is not working. I have delited the contacts on my pc that I wish to change and then went to the advance tab and said replace the contacts on my i phone and it does not it brings back all the ones i just deleted.  I even deleted on both the phone and the pc and magically they all re appeared.  Help!!!
    Also i cannot get my calendar to import or sync to my phone at all.  it does not show up in the sync cycle so it can bring it in, but it is in my outlook

    Hi there,
    You may find the troubleshooting steps in the article below helpful.
    iPhone, iPad, iPod touch: Troubleshooting contact and calendar syncing via USB on Windows
    http://support.apple.com/kb/HT1692
    -Griff W.

  • Setting up scanning on my HP 7520 all in one

    Watched the video on setting up my scanning function but when I click on the printer icon in my control panel I do not see "Scanner Action"  I only see printer action??  Please help.  What am I doing wrong.  Can't locate my printer software disc.

    apucciarello,
    Welcome to the HP Forum.
    You may need to (re)install the Printer Full Feature Software for your Printer onto your computer.
    After you install the Software, Double-click the Printer Assistant shorcut on the Desktop to find a Scan feature function (left side).
    General Instructions to Install the Printer Software
    Reminder:
    1.    In most cases, the Solution Center has been replaced by the Printer Assistant.
    2.    The Printer Assistant shortcut will be installed on your Desktop during the last part of the installation.
    ·         Create a Restore Point:   Create a Restore Point – Win7  OR  Create a restore point Win8
    ·         Open  HP Drivers & Downloads
    ·         Enter your Printer Model information
    ·         Select your Printer from the “Results” list
    OR
    ·         Open HP Photosmart 7520 e-All-in-One Printer Drivers
    ·         Enter your Operating System in the Drop-down menu
    ·         Click NEXT and Scroll down
    ·         Look for category Driver - Product Installation Software
    ·         Select the Basic Driver, e-print, or Full Feature Software
    ·         Save the *.exe installation package(s) on your computer
    The file(s) will likely save to the "Downloads “folder.
    Be sure to look for Updates as needed for your installation.  If available, you may download the Print and Scan Doctor and / or other programs from Category – Utilities. 
    ·         If you have ‘Admin’ control, you may highlight the package and “double-click” to install it, else Right-Click, Select run as Administrator and install.
    NOTES: 
    ·         Look at the bottom half of the main webpage for your printer for helpful videos to assist with the installation of the printer software!
    ·         Scroll the video list back and forth until you find the video that most closely matches your situation.
    ·         USB connection:  Download and install the driver software before connecting a USB cable.
    ·         Ethernet:  Connect the printer to the network and (Optional) assign the printer an IP address at the router.  Once the printer is connected to the network, be sure the printer is switched on and then install the printer software.
    ·         After the initial installation is complete and working, check / install Category  - Update
    There is valuable information at the printer’s website, including manuals, how-to pages, a Troubleshooting and SOLUTIONS section, and alerts and notifications for your printer.  Be sure to take an extended look at what is available.  Bookmark the page.
    Remember:  After you install the Printer Software, use the Printer Assistant shortcut on your Desktop or use your Favorite browser and the printer's IP address to access the printer through the EWS.  You can set / change your wireless, assign a static IP address (network tab), check your printer's stats and more.  Excellent!
    Example:
    Click the Kudos Thumbs-Up to show you appreciate the help and time from our Experts.
    Click Accept as Solution when the Answer is a good Fix or Workaround!
    Although I strive to reflect HP's best practices, I do not work for HP. 
    Kind Regards,
    Dragon-Fur

  • Can't set up wireless connection for HP C4385 All-In-One with Windows 7.

    Hi guys,
    I just got a new laptop with Windows 7 64 bit. I already had an HP C4385 All-In-One that I was using with my last computer. I have also just set up a new wireless network because I got a new cable provider. So basically I needed to do everything from the beginning.
    When I inserted the setup CD and ran the setup program, it said I couldn't continue because my OS was not supported. I went to the HP website and found the solution, which was to plug the printer in via USB and let Windows Update find the latest driver. Ok, that's fine, the printer works now when the USB cord is plugged in.
    To set up the wireless connection, the instruction manual says I need to do it through the network setup wizard p on the CD. But that brings me back to my original problem-- the setup CD won't work because it doesn't recognise Windows 7.
    So my question is-- how can I update the network settings (SSID and key) on the printer without the network setup wizard?
    Thanks for any help, this is really driving me crazy!

    Download from hp.com here.
    Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
    I am employed by HP

  • Cannot update drivers error code 193 on All in one 8500 Win 8.1

    Running Win 8.1 updated from 7.. All in One 8500 910A Can do basic printing but no longer have twain support for scanning etc. When trying to update get failure notice error number 193. HP message says they have no further advice

    Hi @clamproad ,
    I see that you no longer can scan after updating to Windows 8.1. When you try to update, you are getting a failure notice error number 193. I would like to help you resolve this issue.
    Did you fully uninstall the old HP Software and try downloading the newest software?
    Here are the Full Feature Software Drivers if you haven't installed them.
    HP Officejet Pro 8500A e-All-in-One Printer - A910a Drivers.
    Select your operating system, click next and click on the software to download and install.
    Here is a document on this issue. After Upgrading the Computer to Windows 8.1, the HP Printer Does Not Print and the Printer Software ...
    How is the printer connected? (USB/Ethernet/Wireless)
    If you need further assistance, just let me know.
    Have a nice day!
    Thank You.
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" on the right to say “Thanks” for helping!
    Gemini02
    I work on behalf of HP

  • How to put grouped results all on one line.

    I amt trying to get Principal, Interest, Principal YTD, Interest YTD from a transaction table to get them all on one line, but I can't seem to get it. I have a script here that can run without modification to see what I have here. The very last query is
    incorrect, as it puts each value on a separate line, but it demonstrates what I am getting so far. What I want is one account number with 4 columns, as above mentioned. Keep in mind, in this illustration, YTD is last year and forward:
    CREATE TABLE #a
    PMT_ID INT IDENTITY(1,1),ACCT_NO INT, PMT_TYPE CHAR(1), PMT_AMT MONEY, PMT_DATE DATE)
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 1, 'P', 450, '2012-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 1, 'I', 100, '2012-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 1, 'P', 450, '2012-10-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 1, 'I', 100, '2012-11-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 1, 'P', 450, '2012-12-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 1, 'I', 100, '2012-12-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 2, 'P', 351, '2012-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 2, 'I', 102, '2012-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 2, 'P', 352, '2012-10-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 2, 'I', 102, '2012-11-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 2, 'P', 353, '2012-12-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 2, 'I', 102, '2012-12-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 3, 'P', 850, '2013-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 3, 'I', 200, '2013-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 3, 'P', 880, '2013-10-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 3, 'I', 201, '2013-11-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 3, 'P', 855, '2013-12-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 3, 'I', 203, '2013-12-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 1, 'P', 451, '2013-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 1, 'I', 99, '2013-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 1, 'P', 451, '2013-10-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 1, 'I', 99, '2013-11-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 1, 'P', 451, '2013-12-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 1, 'I', 99, '2013-12-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 2, 'P', 352, '2013-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 2, 'I', 101, '2013-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 2, 'P', 353, '2013-10-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 2, 'I', 103, '2013-11-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 2, 'P', 354, '2013-12-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 2, 'I', 103, '2013-12-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 3, 'P', 851, '2013-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 3, 'I', 199, '2013-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 3, 'P', 881, '2013-10-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 3, 'I', 201, '2013-11-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 3, 'P', 854, '2013-12-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES ( 3, 'I', 205, '2013-12-01')
    SELECT PMT_ID, ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE
    FROM #a
    SELECT ACCT_NO, SUM(PMT_AMT) TOT_PRINCIPAL_PAID
    FROM #a
    WHERE PMT_TYPE = 'P'
    GROUP BY ACCT_NO
    SELECT ACCT_NO, SUM(PMT_AMT) TOTAL_INTEREST_PAID
    FROM #a
    WHERE PMT_TYPE = 'I'
    GROUP BY ACCT_NO
    SELECT ACCT_NO, SUM(PMT_AMT) TOTAL_PRINCIPAL_PAID_YTD
    FROM #a
    WHERE PMT_TYPE = 'P'
    AND DATEPART(year,[PMT_DATE])=DATEPART(year,DATEADD(year,-1,GETDATE()))
    GROUP BY ACCT_NO
    SELECT ACCT_NO, SUM(PMT_AMT) TOTAL_INTEREST_PAID_YTD
    FROM #a
    WHERE PMT_TYPE = 'I'
    AND DATEPART(year,[PMT_DATE])=DATEPART(year,DATEADD(year,-1,GETDATE()))
    GROUP BY ACCT_NO
    SELECT ACCT_NO
    ,SUM(PMT_AMT) AS TOTAL_PRINCIPAL_PAID
    ,NULL AS TOTAL_INTEREST_PAID
    ,NULL AS TOTAL_PRINCIPAL_PAID_YTD
    ,NULL AS TOTAL_INTEREST_PAID_YTD
    FROM #a
    WHERE PMT_TYPE = 'P'
    GROUP BY ACCT_NO
    UNION
    SELECT ACCT_NO
    ,NULL AS TOTAL_PRINCIPAL_PAID
    ,SUM(PMT_AMT) AS TOTAL_INTEREST_PAID
    ,NULL AS TOTAL_PRINCIPAL_PAID_YTD
    ,NULL AS TOTAL_INTEREST_PAID_YTD
    FROM #a
    WHERE PMT_TYPE = 'I'
    GROUP BY ACCT_NO
    UNION
    SELECT ACCT_NO
    ,NULL AS TOTAL_PRINCIPAL_PAID
    ,NULL AS TOTAL_INTEREST_PAID
    ,SUM(PMT_AMT) AS TOTAL_PRINCIPAL_PAID_YTD
    ,NULL AS TOTAL_INTEREST_PAID_YTD
    FROM #a
    WHERE PMT_TYPE = 'P'
    AND DATEPART(year,[PMT_DATE])=DATEPART(year,DATEADD(year,-1,GETDATE()))
    GROUP BY ACCT_NO
    UNION
    SELECT ACCT_NO
    ,NULL AS TOTAL_PRINCIPAL_PAID
    ,NULL AS TOTAL_INTEREST_PAID
    ,NULL AS TOTAL_PRINCIPAL_PAID_YTD
    ,SUM(PMT_AMT) AS TOTAL_INTEREST_PAID_YTD
    FROM #a
    WHERE PMT_TYPE = 'I'
    AND DATEPART(year,[PMT_DATE])=DATEPART(year,DATEADD(year,-1,GETDATE()))
    GROUP BY ACCT_NO
    -- Query to put this all these 4 columns on the same line, ending up with 3 lines.
    DROP TABLE #a

    Try the below query
    CREATE TABLE #a
     PMT_ID INT IDENTITY(1,1),ACCT_NO INT, PMT_TYPE CHAR(1), PMT_AMT MONEY, PMT_DATE DATE)
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 1, 'P', 450, '2012-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 1, 'I', 100, '2012-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 1, 'P', 450, '2012-10-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 1, 'I', 100, '2012-11-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 1, 'P', 450, '2012-12-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 1, 'I', 100, '2012-12-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 2, 'P', 351, '2012-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 2, 'I', 102, '2012-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 2, 'P', 352, '2012-10-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 2, 'I', 102, '2012-11-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 2, 'P', 353, '2012-12-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 2, 'I', 102, '2012-12-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 3, 'P', 850, '2013-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 3, 'I', 200, '2013-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 3, 'P', 880, '2013-10-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 3, 'I', 201, '2013-11-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 3, 'P', 855, '2013-12-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 3, 'I', 203, '2013-12-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 1, 'P', 451, '2013-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 1, 'I', 99, '2013-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 1, 'P', 451, '2013-10-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 1, 'I', 99, '2013-11-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 1, 'P', 451, '2013-12-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 1, 'I', 99, '2013-12-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 2, 'P', 352, '2013-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 2, 'I', 101, '2013-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 2, 'P', 353, '2013-10-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 2, 'I', 103, '2013-11-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 2, 'P', 354, '2013-12-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 2, 'I', 103, '2013-12-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 3, 'P', 851, '2013-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 3, 'I', 199, '2013-09-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 3, 'P', 881, '2013-10-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 3, 'I', 201, '2013-11-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 3, 'P', 854, '2013-12-01')
    INSERT INTO #a ( ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE ) VALUES  ( 3, 'I', 205, '2013-12-01')
    SELECT PMT_ID, ACCT_NO, PMT_TYPE, PMT_AMT, PMT_DATE 
    FROM #a
    SELECT ACCT_NO, SUM(PMT_AMT) TOT_PRINCIPAL_PAID
    FROM #a
    WHERE PMT_TYPE = 'P'
    GROUP BY ACCT_NO
    SELECT ACCT_NO, SUM(PMT_AMT) TOTAL_INTEREST_PAID
    FROM #a
    WHERE PMT_TYPE = 'I'
    GROUP BY ACCT_NO
    SELECT ACCT_NO, SUM(PMT_AMT) TOTAL_PRINCIPAL_PAID_YTD
    FROM #a
    WHERE PMT_TYPE = 'P'
    AND DATEPART(year,[PMT_DATE])=DATEPART(year,DATEADD(year,-1,GETDATE()))
    GROUP BY ACCT_NO
    SELECT ACCT_NO, SUM(PMT_AMT) TOTAL_INTEREST_PAID_YTD
    FROM #a
    WHERE PMT_TYPE = 'I' 
    AND DATEPART(year,[PMT_DATE])=DATEPART(year,DATEADD(year,-1,GETDATE()))
    GROUP BY ACCT_NO
    select 
    T123.ANO,
    SUM(TOTAL_PRINCIPAL_PAID) TOTAL_PRINCIPAL_PAID,
    SUM(TOTAL_INTEREST_PAID) TOTAL_INTEREST_PAID ,
    SUM(TOTAL_PRINCIPAL_PAID_YTD) TOTAL_PRINCIPAL_PAID_YTD,
    SUM(TOTAL_INTEREST_PAID_YTD) TOTAL_INTEREST_PAID_YTD
    from
    SELECT ACCT_NO ANO
    ,SUM(PMT_AMT) AS TOTAL_PRINCIPAL_PAID
    ,NULL AS TOTAL_INTEREST_PAID
    ,NULL AS TOTAL_PRINCIPAL_PAID_YTD
    ,NULL AS TOTAL_INTEREST_PAID_YTD
    FROM #a
    WHERE PMT_TYPE = 'P'
    GROUP BY ACCT_NO
    UNION
    SELECT ACCT_NO
    ,NULL AS TOTAL_PRINCIPAL_PAID
    ,SUM(PMT_AMT) AS TOTAL_INTEREST_PAID
    ,NULL AS TOTAL_PRINCIPAL_PAID_YTD
    ,NULL AS TOTAL_INTEREST_PAID_YTD
    FROM #a
    WHERE PMT_TYPE = 'I'
    GROUP BY ACCT_NO
    UNION
    SELECT ACCT_NO
    ,NULL         AS TOTAL_PRINCIPAL_PAID
    ,NULL         AS TOTAL_INTEREST_PAID
    ,SUM(PMT_AMT) AS TOTAL_PRINCIPAL_PAID_YTD
    ,NULL         AS TOTAL_INTEREST_PAID_YTD
    FROM #a
    WHERE PMT_TYPE = 'P'
    AND DATEPART(year,[PMT_DATE])=DATEPART(year,DATEADD(year,-1,GETDATE()))
    GROUP BY ACCT_NO
    UNION
    SELECT ACCT_NO
    ,NULL         AS TOTAL_PRINCIPAL_PAID
    ,NULL         AS TOTAL_INTEREST_PAID
    ,NULL         AS TOTAL_PRINCIPAL_PAID_YTD
    ,SUM(PMT_AMT) AS TOTAL_INTEREST_PAID_YTD
    FROM #a
    WHERE PMT_TYPE = 'I'
    AND DATEPART(year,[PMT_DATE])=DATEPART(year,DATEADD(year,-1,GETDATE()))
    GROUP BY ACCT_NO)T123
    Group by T123.ANO 
    DROP TABLE #a

  • HP update HP Officejet 6500A Plus e-All-in-One Printer-E710n multi fails @ 96%Z

    HP Officejet 6500A Plus e-All-in-One Printer - E710n
    Windows Vista
    HP is trying to update my HP Officejet 6500A Plus e-All-in-One Printer - E710n w/ "HPZSetup.exe & multi fails @ 96%
    Errors:
    HP-PhotoSmart All-In-One Series "Error" "wStub" "2229580"
         Same message appeared multiple times with new numbers: 459624; 525134; 328216
    I am on WIFI but system always shows me on USB.  I thought maybe that was the problem so I connected by USB. No Help.
    I assume this is an update??  HP is insistant and keeps sending me this update which alwaysends in FATAL ERROR at 96%
    Next steps??  Thanks JLM_JR
    This question was solved.
    View Solution.

    No Problem. Is everything working now or this tool only removed the HP software? If so, then try downloading the full feature software to see if this fails or not here. Please choose your correct operating system; Either 32 bit or 64 bit. I will be looking forward to hearing from you.
    I worked on behalf of HP.

  • Error when scanning on L7680 all-in-one

    About a week ago my HP officejet pro L7680 all-in-one will no longer will scan with the hp solution Center software.
    I am on Windows 7 - 32 bit.
    The printer and PC are hard wired to router.
    I get this error Scan cannot be performed because another program or computer is using the networked hp imaging device.
    I see lots of stuff on the internet about this but none that I understand helps.
    Please help
    thx
    Ralph

    Hi ralph_kubota_ma,
    Not quite.
    When you clicked on the blue links in the post that mentions the Level 3 Uninstall and such, did you get a chance to read through each link and follow them step by step? Each link has instructions for how to do each task
    For the Level 3 Uninstall, click here for instructions.
    For clearing your Temp folder, click here for instructions.
    For the HP Printer Install Wizard, click here to download.
    If you run into issues, please let me know where in the document the problem arose. Good luck!
    Please click “Accept as Solution ” if you feel my post resolved your issue, as it will help others find the solution faster
    Click the “Kudos Thumbs Up" on the right to say “Thanks” for helping!
    **MissTeriLynn**
    I work on behalf of HP

  • Computer dies when connecting Double Dragon All-in-One Driver

    I connected a DVD drive with the Double Dragon All in One Driver, via it's USB cable, to my Toshiba Satellite T115 S1100. I have done this numerous times before and there has been no problem. On this occasion I moved the power cable from the DVD to the power socket on the unit and as I inserted it the computer hard drive clicked and the computer went dead. It is now as dead as 'a dodo' and I assuming that there has been a power surge through the USB cable. Does anyone have any thoughts or have I 'toasted' the motherboard or some other part of the computer? Many thanks Peter
    Solved!
    Go to Solution.

    I contacted Toshiba, who were very helpful but were unable to suggest a solution, without seeing the machine.
    However, I took the battery out, whilst I was working on another laptop. When I returned and placed the battery back in, lo and behold, it came on and seems to be unaffected by whatever happened. So many thanks to anyone who may have viewed this blog, but the issue is solved.  Peter 

  • Having problem deleting all but one particular mail from the iPhone 4S mail inbox. I can delete mail either by the trash can or using edit, selecting the mail message and deleting.  However there is this one mail message that will not go away. Any ideas?

    I am having a problem deleting all but one particular mail message from my inbox. I delete by either using the trash can icon for individual mail, or using edit, selecting the mail message (s) and clicking delete.  However there is this one mail message that will not go away regardles of what I do including deleting all from the trash.  Any ideas?

    I get that every once in a while on my 3GS, and that's what I do to get rid of it. Probably not a bad idea to power down the phone every so often, anyway, gets rid of any crud waiting to cause a bug.
    Glad to hear that it worked for you.

  • How do you set up airport extreme with a windstream all in one modem with the wireless router built in

    I have a wireless network that I want to extend so there will be wifi coverage all over the whole house. I want to use the airport extreme to do so. so far all i can get to work is the airport making another network via a eithernet cable that is pluged into one of the ports on the windstream wireless router/moden (all in one you plug the phone line into this and it has the wireless built in) and the other end is in the WAN port of the airport. I guess the real question is do I need to change any settings on the windstream wireless router/modem to do so. Every time I select all the options to extend a network wirelessly I keep getting errors.

    The Airport Extreme can not wirelessly extend a 3rd party router, it can only extend another Apple router. If you can somehow keep the two connected via ethernet, you can setup a roaming network. A roaming network is essentially "extending" your network by using an ethernet cable to bridge the two routers.

  • Windows 8.1 error when printing photsmart B110 all in one series

    When going to print a document of more than one page the system goes into print mode but after a short delay the windows error screen appears saying there was an error to the printer. Howvever the printer some times prints the whole document or only part of the documnet. In the documents outstanding page the window shows the print are queing. All the wirless network test report everyting is ok and it prints a test page ok.

    Welcome to the forums malvernlink_asp,
    I saw your post about the printing troubles you are having with your Windows 8.1 system and Photosmart B110. I will gladly do my best to help you!
    Please make a couple of copies and let me know if the copies work successfully or if there is an issue with them. This will tell us if there is a hardware issue with the printer itself.
    If the copies work fine, please run the HP Print and Scan Doctor from your computer and write me back with the detailed results or send me a screen shot.
    Have you tried printing from different programs? If not, try different programs so we know if the problem is only within one program, or all of them.
    Try power cycling the network devices:
    Turn off the printer and computer and unplug the router for 1 minute (do not press any buttons on the router).
    Plug the router back in and wait another minute, next turn on the printer and computer.
    Have you tried uninstalling and reinstalling the software? If not, you can try this as well.
    What Firewalls and Anti-virus software are installed? Have you tried disabling or uninstalling them?
    Hope to hear back from you, have a great day!
    R a i n b o w 7000I work on behalf of HP
    Click the “Kudos Thumbs Up" at the bottom of this post to say
    “Thanks” for helping!
    Click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution!

  • Update server not responding photosmart 410 all-in-one

    Hi all,
    I'm new to blogging and not too computer savvy so patience please. This problem looks like it's been posted before but I'm not sure how to apply it to me.  I have a 410a printer connected to a minimac running OSx 10.10 (yosemite?). I am trying to update software to prevent duplicates printing after turning off the computer. When I go through the procedure to run update the printer screen says it had a problem connecting to the server.
    I tried the printer IP address in Safari and Firefox but both say server is not responding. Is the server down, or is a problem with my setup?
    Help - and thanks
    This question was solved.
    View Solution.

    Hello HevnLgh,
    Thank you for your input. I tried to follow your instructions but had trouble right from the start. I got to HP uninstaller and clicked continue but there was no printer listed. It just said "device" and uninstall was greyed out. I decided to just continue so I reset the printing system and repaired the  disk permissions. 
    It took me a couple of tries to reinstall the printer from the Apple website because at first it couldn't find the device to add so I tried using the IP address on the next tab and that seemed to do something but it still wouldn't print. The printer was found after I  went back and tried again and everything seemed to work this time (whew).
    I tried the update procedure on the printer itself and it still can't connect with the server, but the original problem with the duplicate copy on shut down seems to have resolved itself.
    The bottom line is my printer is working like it's supposed to (for now anyway)  and I didn't get two copies of my printout so thank you again for your help.  It's good to know I can go somewhere for help when I have a problem.

Maybe you are looking for

  • Export/Convert to h.264 results in jerky video in WMP

    System: Windows 7 Ultimate x64 EN In Premiere Pro CS4 and Adobe Media Encoder CS4 I have problems exporting video to h.264. Please download the sample file here: http://www.tsxn.com/storage/transfer/premiere_h264.zip Source:   H.264 HDTV Testvideo (e

  • Lennovo T60 with Win 8.1 Pro: Bluetooth not working

    Hi, I have a T60 with win 8.1 pro. Bluetooth menu doesnt show up in device manager or under the PC and Devices. Please help to get the bluetooth menu on PC, I need to connect a microsoft bluetooth mouse. Thanks Sal

  • Aperture doesn't start after Mountain Lion update

    Hi, I've been using Aperture 3 for a while without problems. It's the version that came out last before Aperture went into the app store (and the price was reduced). All updates have been installed since then without any problems. Today I got my new

  • Is there a way to quantize the length of the notes?

    Hi there Logic Studio is really smart. It knows how long I intended a note to be, so even if I hold it down a bit too short or a bit too long it will print me the desired note. However, if I export this file into a notation program (Finale 07), this

  • Setting individual podcast preferences

    I'm trying to set podcast A to automatically delete after I listen to it while setting podcast B NOT to delete after I listen to it. I don;t think this is possible in iTunes, but is there 3rd party software, apple scripts, or automator actions that c