Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Group by summary
Message
From
06/08/2007 07:05:24
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
06/08/2007 04:45:55
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01246096
Message ID:
01246109
Views:
17
>Dear Experts
>
>Table1 has four fields as
>
>code n(4)
>name n(4)
>amount n(5)
>type c(1)
>
>Data in fields is as
>
>code----name----amount--type
>1101----Eric-----100-----B
>1202----Bill-------200-----B
>1506----Boris----600-----A
>1608----Cetin----900-----A
>1709----Jack-----800-----A
>2101----Ali--------900-----B
>2202----Tame---100-----A
>2608----Zahi-----100-----A
>
>I need following output based on two conditions
>
>Group + type
>Every group is based on First digit of code
>Type is based on A and B
>
>Codes between 1100 to 1900 is Group 1
>Codes between 2000 to 2900 is Group 2 and so on
>
>This should be Final Output
>
>code----name----amount--type
>2--------2-------300------B && total of group 1 with type=B
>3--------3-------1700-----A && total of group 1 with type=A
>1--------1-------900------B && total of group 2 with type=B
>2--------2-------200------A && total of group 2 with type=A
>
>
>Please help
select ;
 icase( ;
  between(code, 1100,1900), 1, ;
  between(code, 2000,2900), 2, ;
  3) as myGroup, type, sum(amount) as totAmt from myTable group 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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform