Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Double group by
Message
 
 
À
06/04/2017 04:24:43
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows 7
Network:
Windows Server 2008 R2
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01649833
Message ID:
01649835
Vues:
49
>Dear Experts
>
>I have these codes
>
>
>
>SELECT acc_code,sum(open_dr) as dr_amount,sum(open_cr) as cr_amount
> from master where LEN(acc_code)>4 and left(acc_code,4)='2305'
> group by acc_code
>
>
>
>the codes generates results group by acc_code like shown in attachment.
>
>But I need sum of all codes in single row like this
>
>2305-245585-356588
>
>I used this query but it does not work
>
>
>SELECT acc_code,sum(open_dr) as dr_amount,sum(open_cr) as cr_amount
> from master where LEN(acc_code)>4 and left(acc_code,4)='2305'
> group by LEFT(acc_code,2)='23'
>
>
>Please help
select min(acc_code) + '-' + max(acc_code) as AccountRanges, sum(open_dr) as dr_Amount, sum(open_cr) as cr_Amount
from dbo.master where acc_code like '2305%' and len(acc_code) > 4
The above will generate a single row showing the range of accounts. If you want to list all accounts in a single row, that query will need to be slightly modified.

You're using SQL Server, right?
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform