Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Help Needed Please!
Message
De
23/08/2001 17:31:09
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00548100
Message ID:
00548353
Vues:
21
This message has been marked as a message which has helped to the initial question of the thread.
>Hi Cetin!
>
>Yeah, I know how to do it in a report form. What I'm trying to do is end up with a cursor that looks like this:
>
>
>Company Divsion
>JOHN SMITH, INC. WEST
> SOUTH
> EAST
>
>Instead of:
>JOHN SMITH, INC. WEST
>JOHN SMITH, INC. SOUTH
>JOHN SMITH, INC. EAST
>
>I know there are other ways to do it, but is there a way to do it in ONE SQL statement, maybe using UNION or something??
>
>-thanks

Kevin,
Your intention wasn't a ONE SQL as I could see. Anyway if I really ever needed to do it in one SQL this would be one way :
SELECT a.cust_id as sort1,b.order_id as sort2, ;
 a.cust_id, a.company, b.order_id,b.to_name;
 FROM  customer a INNER JOIN orders b ;
   ON  a.cust_id = b.cust_id ;
   where order_id = ; 
(select min(order_id) from orders C where b.cust_id = c.cust_id) ; 
union ;
SELECT a.cust_id as sort1,b.order_id as sort2, ;
 '' as cust_id, '' as company, b.order_id,b.to_name;
 FROM  customer a INNER JOIN orders b ;
   ON  a.cust_id = b.cust_id ;
   where order_id # ; 
(select min(order_id) from orders C where b.cust_id = c.cust_id) ; 
order by 1,2
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform