Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
SQL Server 2008 - General
»
How can I delete records base on the value of...
How can I delete records base on the value of a fieled in the 1st recor?
Rate Topic
Display Mode
Topic Options
Author
Message
doug 37293
doug 37293
Posted Monday, December 31, 2012 4:01 PM
Grasshopper
Group: General Forum Members
Last Login: Friday, April 26, 2013 8:32 AM
Points: 17,
Visits: 68
I generate a small table with a SELECT INTO from a larger table. One of the fields in the new table is 'Org'. I have to treat Org = ABC as a special case. So IF the Org in the first row is ABC, DELETE all other rows.
If the Org in the first row is NOT ABC, keep all rows.
How would I construct this query?
Post #1401520
opc.three
opc.three
Posted Monday, December 31, 2012 5:12 PM
SSCertifiable
Group: General Forum Members
Last Login: Today @ 8:27 PM
Points: 6,735,
Visits: 11,788
Sounds like homework, which is fine, I am happy to help, but please post the some table definitions (CREATE TABLE statements) and some sample data (INSERT statements) as well as your expected results (per the sample data).
__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
Believe you can and you're halfway there.
--Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler
--Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them.
--Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples.
--Giordy
Post #1401530
Lynn Pettis
Lynn Pettis
Posted Monday, December 31, 2012 7:41 PM
SSC-Insane
Group: General Forum Members
Last Login: Today @ 9:51 PM
Points: 21,627,
Visits: 27,482
opc.three (12/31/2012)
Sounds like homework, which is fine, I am happy to help, but please post the some table definitions (CREATE TABLE statements) and some sample data (INSERT statements) as well as your expected results (per the sample data).
Plus what you have written so far in an effort to solve your problem.
It helps to know what you have done so that we can guide to the correct solution.
Lynn Pettis
For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here
or
when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here
and
here
Managing Transaction Logs
SQL Musings from the Desert
Fountain Valley SQL
(My Mirror Blog)
Post #1401540
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.