Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Divided Operator Expand / Collapse
Author
Message
Posted Friday, July 24, 2009 4:16 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, January 21, 2010 12:29 PM
Points: 4, Visits: 166
How do we implement DIVIDE OPERATOR in SQL?
Post #758915
Posted Friday, July 24, 2009 12:36 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, April 2, 2010 6:41 AM
Points: 54, Visits: 134
What are you trying to do? More information is neccessary.

Eli
Post #759415
Posted Friday, July 24, 2009 1:11 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 9:09 AM
Points: 10,342, Visits: 13,352
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

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
Post #759451
Posted Friday, July 24, 2009 2:08 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, January 21, 2010 12:29 PM
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)
Post #759493
Posted Friday, July 24, 2009 4:54 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 10:20 AM
Points: 12,927, Visits: 32,332
still not clear to me either, can you give a non-pseudo code, concrete example of the expected results?

Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #759548
Posted Friday, July 24, 2009 5:04 PM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: 2 days ago @ 4:49 PM
Points: 866, Visits: 7,478
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
Post #759551
Posted Saturday, July 25, 2009 3:02 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Wednesday, November 19, 2014 12:12 PM
Points: 451, Visits: 3,466
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.


David
Post #759598
Posted Saturday, July 25, 2009 3:36 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, January 21, 2010 12:29 PM
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
)



/*
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'
*/
Post #759600
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse