Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

query required Expand / Collapse
Author
Message
Posted Thursday, June 20, 2013 6:24 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, June 25, 2013 1:34 PM
Points: 14, Visits: 19
Dear all,

I have following tables

TABLE : A

ENTERPRISE_MAIN_CODE ENTERPRISE_SUB_CODE ENTERPRISE_DESCRIPTION
1 0 A
2 0 B
3 0 C
4 0 D
5 0 E
6 0 F
7 0 G
8 0 H
9 0 I

TABLE : B

ID_NO ENTERPRISE_MAIN_CODE ENTERPRISE_SUB_CODE
1 1 1
2 1 2
3 7 1
4 4 1
5 4 1
6 6 1
7 6 5


TABLE : C
ID_NO ENTERPRISE_ID_NO ENTERPRISE_DATE ENTERPRISE_AMT
1 1 20130109 1000
1 2 20130315 2000
2 3 20120120 3000
2 4 20120305 4000
3 5 20141111 5000
4 6 20130115 6000
5 7 20130320 7000


the expected op is as follows. op is based on the year 201303.




ENTERPRISE_DESCRIPTION count amt count amt count amt count amt
A 1 2000 1 4000 2 3000 2 7000

B 0 0 0 0 0 0 0 0

C 0 0 0 0 0 0 0 0

D 1 7000 0 0 2 13000 0 0

E 0 0 0 0 0 0 0 0

F 0 0 0 0 0 0 0 0

G 0 0 0 0 0 0 0 0

H 0 0 0 0 0 0 0 0

I 0 0 0 0 0 0 0 0
Thanks

Nick
Post #1465627
Posted Thursday, June 20, 2013 7:08 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Yesterday @ 6:20 PM
Points: 33,078, Visits: 15,192
Happy to help, but we don't like to do homework, tests, or work work for you. Make an attempt.

You haven't really explained how the data should be joined, or given any DDL/DML to help us set up a scenario. Most importantly, you didn't make any query attempt to get this to work yourself.







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1465672
Posted Thursday, June 20, 2013 7:10 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, July 16, 2014 8:33 AM
Points: 2,616, Visits: 4,720
Duplicate post. Please direct all the replies here
http://www.sqlservercentral.com/Forums/Topic1465520-391-1.aspx



Kingston Dhasian

How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1465675
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse