Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL SELECT help needed.
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00401104
Message ID:
00401174
Views:
18
Steve: This query works for the specific data you've provided. I'm not sure if it will work in all cases though

SELECT * FROM table ;
WHERE NOT EMPTY(Field3);
OR ;
Field1 IN (SELECT Field1 FROM table GROUP BY Field1 HAVING COUNT(*) = 1)



>I SELECTing records in a table, but don't know how to get what I want. Here's what I am SELECTing:
>
>Field1 Field2 Field3 Field4
>100 A
>100 A A A
>200 A
>200 A A A
>300 A
>300 A A A
>300 A B B
>400 A
>500 A
>500 A A A
>
>I want to discard all records that are EMPTY(Field3) AND
>EMPTY(Field4) AND also have a duplicate number in Field1 like where Field1 = 100 and Field1 = 200 and Field1 = 300 and Field1 = 500. The first record of all those sets of records would be discarded. I would only SELECT all the records after the first record of those sets.
>But I don't want to discard any records where Field 1 does not have a duplicate number in Field1 like where Field1 = 400. I would want to select the one and only record for Field1 = 400.
>
>So the result of my SELECT would be:
>
>Field1 Field2 Field3 Field4
>100 A A A
>200 A A A
>300 A A A
>300 A B B
>400 A
>500 A A A
>
>How can I do this with a SELECT? TIA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform