SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


query required


query required

Author
Message
nicklibee
nicklibee
Grasshopper
Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)

Group: General Forum Members
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
Steve Jones
Steve Jones
SSC Guru
SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)

Group: Administrators
Points: 145845 Visits: 19425
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
My Blog: www.voiceofthedba.com
Kingston Dhasian
Kingston Dhasian
SSCertifiable
SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)

Group: General Forum Members
Points: 6010 Visits: 5280
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/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search