Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM SQL » View Thread |
Messages 1 to 4 of 4 total |
Need more clever solution for a selection |
Thu, Mar 28 2013 8:23 AM | Permanent Link |
marcioehrlich | I need to select from a table where some records may be in two different groups. For instance, in this list, I need to select only those names who are exclusive in the particular group "A".
Grp Name A John B Bob A Bob A Peter B James So, I would only get John and Peter, since Bob belongs to "A" and "B". I've tried this but it looked a little bit too much having to select twice the table: SELECT Name FROM TableList WHERE Grp = 'A' AND Name NOT IN (SELECT Name FROM TableList WHERE Grp <> 'A') Can anyone suggest me a better solution? Tks, Marcio Ehrlich |
Fri, Mar 29 2013 1:07 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Marcio,
<< I need to select from a table where some records may be in two different groups. For instance, in this list, I need to select only those names who are exclusive in the particular group "A". >> You could also use EXCEPT: SELECT Name FROM TableList WHERE Grp = 'A' EXCEPT SELECT Name FROM TableList WHERE Grp <> 'A' Tim Young Elevate Software www.elevatesoft.com |
Fri, Mar 29 2013 1:18 PM | Permanent Link |
marcioehrlich | It looks like there is no way of avoiding both selections. I'll try to learn more about "EXCEPT".
Thank you, Tim. M. "Tim Young [Elevate Software]" wrote: SELECT Name FROM TableList WHERE Grp = 'A' EXCEPT SELECT Name FROM TableList WHERE Grp <> 'A' |
Mon, Apr 1 2013 5:08 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Marcio,
<< It looks like there is no way of avoiding both selections. I'll try to learn more about "EXCEPT". >> No, you can't avoid that. It's really a matter of which syntax you prefer. Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Monday, May 6, 2024 at 12:23 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |