Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.databases.ms-sqlserver    |    Notorious Rube Goldberg contraption    |    19,505 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 19,165 of 19,505    |
|    Ross Presser to --CELKO--    |
|    Re: How to I select to show only those t    |
|    09 Feb 15 21:21:35    |
      From: rpresser@gmail.com              On Sunday, February 8, 2015 at 12:35:49 PM UTC-5, --CELKO-- wrote:       [snip]       > CREATE TABLE Ridership       > (social_nbr CHAR(15) NOT NULL       > REFERENCES Ridership (social_nbr)        ^^^^^^^^^       What?       You meant Riders, right?              Furthermore, he stated that each horse is only owned (or ridden)       by one Rider. You haven't captured that in your DDL.              > ON UPDATE CASCADE       > ON DELETE CASCADE,       > horse_nbr CHAR(15) NOT NULL       > REFERENCES Horse(horse_nbr)       > ON UPDATE CASCADE       > ON DELETE CASCADE,       > PRIMARY KEY (rider_nbr, horse_nbr));       >       > >> How do I change this query if I only want to list those that have more       than one horse. <<       >       > SELECT social_nbr       > FROM Ridership       > GROUP BY social_nbr       > HAVING COUNT(horse_nbr) > 1;       >       > 85-90% of the work in SQL is in the DDL, not the DML.              And the last 10% of helping someone is not messing up the answer.              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca