473,378 Members | 1,482 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

MSQL UPDATE table

benchpolo
142 100+
Tablename: CLAIMS
Fields: PATID, REVENUE, CLAIMNO

DATA

235101133A, 6117.84, 200705455201111
235101133A, 6117.84, 200605599902888

Question?
I have a set of data records where the REVENUE is calculated monthly by PATID. The PATID can appear more than once in a set of data records where the CLAIMNO is unique.

The problem I'm having is that "unique" PATID can only have one calculated REVENUE. As you can see from above example 6117.84 appeared twice in the record set due to a different claimno.

What I want to accomplish is to keep the earliest or recent CLAIMNO entered in the system and update the REVENUE field, but zero out the remainder of the data whether there are more claimno related to the same PATID. Does it make sense?

Please advise. Thanks
May 2 '08 #1
3 1312
ck9663
2,878 Expert 2GB
Tablename: CLAIMS
Fields: PATID, REVENUE, CLAIMNO

DATA

235101133A, 6117.84, 200705455201111
235101133A, 6117.84, 200605599902888

Question?
I have a set of data records where the REVENUE is calculated monthly by PATID. The PATID can appear more than once in a set of data records where the CLAIMNO is unique.

The problem I'm having is that "unique" PATID can only have one calculated REVENUE. As you can see from above example 6117.84 appeared twice in the record set due to a different claimno.

What I want to accomplish is to keep the earliest or recent CLAIMNO entered in the system and update the REVENUE field, but zero out the remainder of the data whether there are more claimno related to the same PATID. Does it make sense?

Please advise. Thanks
If the REVENUE is the same for all PATID, this should be enough

INSERT INTO YourTable (PATID, REVENUE)
select PATID, REVENUE from CLAIMS group by PATID

-- CK
May 2 '08 #2
benchpolo
142 100+
So after I perform the insert statement will my result be like this.

235101133A, 6117.84, 200705455201111
235101133A, <null> , 200605599902888

Thanks.
May 2 '08 #3
ck9663
2,878 Expert 2GB
Use ISNULL or replace all NULL with 0

-- CK
May 2 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: lance | last post by:
Hi Is there any way with a php to find out if a table is locked before using a mysql_query on the table?
1
by: Dinesh Garg | last post by:
Hi All, I want to use MS sql server edition 2000. I have installed the server. Now i want to create the database on this server with tables and triggers. Can please someone suggest me how to do...
0
by: anthony | last post by:
Hi. I am attempting to get msql3 installed with php. Using php version php5.1-200604070430 and msql-3.7. I am getting the following error on compile. ...
0
by: MatchSQL | last post by:
When we want to save the database schema and SQL statement , we use the backup of SQLServer provide, but it always content the running data, now a new tool named MatchSQL, it can just save...
1
by: jf39 | last post by:
Hi, Im just new in this stuff, does anyone know how to fill up a combobox in html using javascript? The info to retrieve is in a table in mysql It would be great if someone could me how to do... ...
3
by: charless | last post by:
I have an application that writes text to a MySQL data base from an HTML form. The text in the MySQL table retains the formatting in the form (line breaks etc.) However when I retrieve the text and...
1
by: ABITECH | last post by:
hi guys I am working on a project in databases using the wamp software. So how do i connect msql to php. Pliz help mi Because i badly nid the code for my project. bye
0
by: Rebles | last post by:
I'm writing a PERL script to access and insert rows into a Microsoft SQL. i'm using MS SQL Server Management Studio Express (2005) to architect tables and queries. I've inserted two records into...
2
by: chazzy69 | last post by:
Ok this may seem a little strange but what i Im trying to add an altered version of information already stored in my database. Basically i have a colum that has strings of numbers and characters,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.