Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Divided Operator


Divided Operator

Author
Message
ms65g
ms65g
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 166
How do we implement DIVIDE OPERATOR in SQL?
stopitallready
stopitallready
Valued Member
Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)Valued Member (54 reputation)

Group: General Forum Members
Points: 54 Visits: 134
What are you trying to do? More information is neccessary.

Eli
Jack Corbett
  Jack Corbett
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11014 Visits: 14858
If you meant the math division operator then you use "/".



Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming
At best you can say that one job may be more secure than another, but total job security is an illusion. -- Rod at work

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
ms65g
ms65g
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 166
stopitallready (7/24/2009)
What are you trying to do? More information is neccessary.

Eli


I mean 8th operator. A divided by B per C
and A,B and C are result set.

A divided by B per C = A minus ( (A times B) minus C)
Lowell
Lowell
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14942 Visits: 38935
still not clear to me either, can you give a non-pseudo code, concrete example of the expected results?

Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

David Webb-CDS
David Webb-CDS
SSC Eights!
SSC Eights! (916 reputation)SSC Eights! (916 reputation)SSC Eights! (916 reputation)SSC Eights! (916 reputation)SSC Eights! (916 reputation)SSC Eights! (916 reputation)SSC Eights! (916 reputation)SSC Eights! (916 reputation)

Group: General Forum Members
Points: 916 Visits: 8584
If you're talking about the relational division operator, a decent explanation with some SQL as an example is http://www.dbazine.com/ofinterest/oi-articles/celko1.

I'm not a big Celko fan, but this (and the included references) should get you started.



And then again, I might be wrong ...
David Webb
sqlvogel
sqlvogel
SSC-Addicted
SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)

Group: General Forum Members
Points: 484 Visits: 3706
Take a look at Vadim Tropashko's book SQL Design Patterns for examples of relational division problems and solutions.

Full marks for a good question by the way. It's a bit unfortunate that Relational Algebra and other relational theory ideas aren't as well appreciated and used in the SQL community as they perhaps ought to be. These concepts give you the tools and a vocabulary for solving lots of every day problems.

Unfortunately, as has often been noted, too many database practitioners today don't know the relational model at all. They just know SQL and someone once told them SQL was relational so they assume they must know the relational stuff too.

Not knocking anyone here BTW. Just my thoughts for this "Relational Theory" forum.

Hope this helps.
ms65g
ms65g
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 166
Thank you.
I agree with you. a lot of difficult problem solve by using relational algebra.
Dr. CJ Date offered two methods but I was looking for the best solution for division operator.

here is a method: Please exec following script before exec this query

-- My Method
SELECT DISTINCT pilot
FROM PilotSkills AS PS
WHERE NOT EXISTS (
            SELECT plane FROM Hangar
            EXCEPT
            SELECT plane FROM PilotSkills
            WHERE PS.pilot=pilot
      Wink



/*
CREATE TABLE PilotSkills
(pilot CHAR(15) NOT NULL,
plane CHAR(15) NOT NULL,
PRIMARY KEY (pilot, plane));

INSERT INTO PilotSkills
SELECT pilot='Celko', plane='Piper Cub'
UNION
SELECT 'Higgins','B-52 Bomber'
UNION
SELECT 'Higgins','F-14 Fighter'
UNION
SELECT 'Higgins','Piper Cub'
UNION
SELECT 'Jones','B-52 Bomber'
UNION
SELECT 'Jones','F-14 Fighter'
UNION
SELECT 'Smith','B-1 Bomber'
UNION
SELECT 'Smith','B-52 Bomber'
UNION
SELECT 'Smith','F-14 Fighter'
UNION
SELECT 'Wilson','B-1 Bomber'
UNION
SELECT 'Wilson','B-52 Bomber'
UNION
SELECT 'Wilson','F-14 Fighter'
UNION
SELECT 'Wilson','F-17 Fighter'

CREATE TABLE Hangar
(plane CHAR(15) NOT NULL PRIMARY KEY);

INSERT INTO Hangar
SELECT plane='B-1 Bomber'
UNION
SELECT 'B-52 Bomber'
UNION
SELECT 'F-14 Fighter'
*/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search