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 12»»

many to many join and union all Expand / Collapse
Author
Message
Posted Wednesday, January 9, 2013 3:19 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, May 20, 2013 7:19 AM
Points: 10, Visits: 51
I'm having a hard time with this query this afternoon. I have 3 tables cash, revenue, expense. I need to join them together keeping all rows along with begin_balance, end_balance, and revenue. There are several rows per building all having different totals.

Sample data:
Revenue_table
building_code - 125, 125, 125
function_code – null, null, null
fund_code - 001, 001, 001
receipt_code – 14, 18, 31
object_code - null, null, null
revenue - 24463.24, 0, 825625.16
begin_balance - null, null, null
end_balance - null, null, null
year - 2007-12


Expense_table
building_code - 125, 125, 125
fund_code - 001, 001, 001
function_code – 11, 11, 11
receipt_code - null, null, null
object_code – 41, 41, 42
revenue - 24463.24, 0, 825625.16
begin_balance - null, null, null
end_balance - null, null, null
year - 2007-12

Cash_table
building_code - 125, 125, 125
function_code - null, null, null
fund_code - 001, 006, 007
receipt_code - null, null, null
object_code - 41, 41, 42
revenue - null, null, null
begin_balance - 206891.77, 0, 424.65
end_balance - 764207, -13522.95, 494.65
year - 2007-12

What is needed is to join on building_code and foreign keys to merge data together than possibly union the tables together creating one table in which all the data exists. I was uncertain as to how to join on tables with many to many relationships without producing unnecessary matches.
Post #1405043
Posted Wednesday, January 9, 2013 3:34 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 2:36 AM
Points: 1,885, Visits: 18,479
Hi

seems you are new around here...so a big welcome ...hopefully you will find this site a friendly and helpful resource.

first off...you have posted in SQL 7 , 2000 forum...is this the SQL version that you are using?
only asking cos it will make a difference to the answers provided......

are you familiar with how to provide "create table" statements and how to provide data to populate said tables ?.....this will make it far more likely that you will receive a tried and tested answer...if not please post back and we can give you some pointers.



__________________________________________________________________
you can lead a user to data....but you cannot make them think !
__________________________________________________________________
Post #1405050
Posted Wednesday, January 9, 2013 3:38 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, May 20, 2013 7:19 AM
Points: 10, Visits: 51
J I am new. Thank you for the welcome. Any pointers will be helpful. SQL Server 7, 2000 is not what I was looking for.
Post #1405051
Posted Wednesday, January 9, 2013 3:44 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 2:36 AM
Points: 1,885, Visits: 18,479
wtolbert (1/9/2013)
J I am new. Thank you for the welcome. Any pointers will be helpful. SQL Server 7, 2000 is not what I was looking for.


ok...what version of MS SQL are you working with?

assuming you already have a SQL table with data called "Revenue_table " ?...correct?

do you know how to script this out (with data) to enable the forum to easily use your output (eg cut and paste into their version of SSMS and thereby replicate what you can see)...??

regards



__________________________________________________________________
you can lead a user to data....but you cannot make them think !
__________________________________________________________________
Post #1405057
Posted Wednesday, January 9, 2013 4:08 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, May 20, 2013 7:19 AM
Points: 10, Visits: 51
I'm using SQL Server 2008 R2 and the tables are not very large but I can condense them to a small sample size and produce the schema and data.
Post #1405065
Posted Wednesday, January 9, 2013 4:11 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 2:36 AM
Points: 1,885, Visits: 18,479
great...look fwd to seeing the scripts

__________________________________________________________________
you can lead a user to data....but you cannot make them think !
__________________________________________________________________
Post #1405066
Posted Wednesday, January 9, 2013 4:36 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, May 20, 2013 7:19 AM
Points: 10, Visits: 51
I have the schema and data. Not sure where I should attach it?
Post #1405072
Posted Wednesday, January 9, 2013 4:43 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 1:58 AM
Points: 6,136, Visits: 7,184
wtolbert (1/9/2013)
I have the schema and data. Not sure where I should attach it?


Instead of attaching it, it's best if you simply put it into the post and wrap it with the code="sql" tags you'll see in the ifCode shortcuts you'll see on the left. Many of us here are a bit fearful of downloading anything from the internet simply because a lot of us are on our work machines.



- Craig Farrell

Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

For better assistance in answering your questions | Forum Netiquette
For index/tuning help, follow these directions. |Tally Tables

Twitter: @AnyWayDBA
Post #1405077
Posted Wednesday, January 9, 2013 5:06 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, May 20, 2013 7:19 AM
Points: 10, Visits: 51
Thanks Craig.

CREATE TABLE [dbo].[RAW_Financial_revenue_test](
[year_time] [varchar](100) NULL,
[district_code] [varchar](150) NULL,
[district_name] [varchar](150) NULL,
[FUND_CODE] [varchar](150) NULL,
[fund_description] [varchar](150) NULL,
[fund_type] [varchar](150) NULL,
[source_data] [varchar](250) NULL,
[source_state] [varchar](100) NULL,
[function_code] [varchar](150) NULL,
[function_description] [varchar](150) NULL,
[source_code] [varchar](100) NULL,
[source_description] [varchar](150) NULL,
[receipt_code] [varchar](100) NULL,
[receipt_description] [varchar](150) NULL,
[object_code] [varchar](100) NULL,
[object_description] [varchar](150) NULL,
[begin_balance] [varchar](100) NULL,
[end_balance] [varchar](100) NULL,
[actual] [varchar](100) NULL,
[budget] [varchar](100) NULL,
[report_type] [varchar](5) NULL,
[account_type_code] [varchar](5) NULL,
[account_type_desc] [varchar](50) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
INSERT [dbo].[RAW_Financial_revenue_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', NULL, NULL, NULL, NULL, NULL, NULL, N'1410', N'Interest on Investments *', NULL, NULL, NULL, NULL, N'24463.24', NULL, N'A', N'R', N'revenue')
INSERT [dbo].[RAW_Financial_revenue_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', NULL, NULL, NULL, NULL, NULL, NULL, N'1890', N'Other Miscellaneous Receipts *', NULL, NULL, NULL, NULL, N'0', NULL, N'A', N'R', N'revenue')
INSERT [dbo].[RAW_Financial_revenue_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', NULL, NULL, NULL, NULL, NULL, NULL, N'3110', N'School Foundation Basic Allowance *', NULL, NULL, NULL, NULL, N'825625.16', NULL, N'A', N'R', N'revenue')
INSERT [dbo].[RAW_Financial_revenue_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', NULL, NULL, NULL, NULL, NULL, NULL, N'3110', N'School Foundation Basic Allowance *', NULL, NULL, NULL, NULL, N'9745.89', NULL, N'A', N'R', N'revenue')
INSERT [dbo].[RAW_Financial_revenue_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', NULL, NULL, NULL, NULL, NULL, NULL, N'3110', N'School Foundation Basic Allowance *', NULL, NULL, NULL, NULL, N'74245.4', NULL, N'A', N'R', N'revenue')
INSERT [dbo].[RAW_Financial_revenue_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', NULL, NULL, NULL, NULL, NULL, NULL, N'3110', N'School Foundation Basic Allowance *', NULL, NULL, NULL, NULL, N'41152.86', NULL, N'A', N'R', N'revenue')
INSERT [dbo].[RAW_Financial_revenue_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'006', N'Food Services ', N'Special Revenue Fund/Permanent fund/Private Purpose fund', NULL, NULL, NULL, NULL, NULL, NULL, N'1512', N'Sales of Type A Lunches to Students *', NULL, NULL, NULL, NULL, N'39', NULL, N'A', N'R', N'revenue')
INSERT [dbo].[RAW_Financial_revenue_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'006', N'Food Services ', N'Special Revenue Fund/Permanent fund/Private Purpose fund', NULL, NULL, NULL, NULL, NULL, NULL, N'4210', N'Restricted Grants-in-aid Received Directly from Federal Government *', NULL, NULL, NULL, NULL, N'3724.8', NULL, N'A', N'R', N'revenue')
INSERT [dbo].[RAW_Financial_revenue_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'007', N'Special Trust ', N'Special Revenue Fund/Private Purpose fund', NULL, NULL, NULL, NULL, NULL, NULL, N'1820', N'Contributions and Donations from Private Sources *', NULL, NULL, NULL, NULL, N'270', NULL, N'A', N'R', N'revenue')
INSERT [dbo].[RAW_Financial_revenue_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'007', N'Special Trust ', N'Special Revenue Fund/Private Purpose fund', NULL, NULL, NULL, NULL, NULL, NULL, N'1820', N'Contributions and Donations from Private Sources *', NULL, NULL, NULL, NULL, N'2500', NULL, N'A', N'R', N'revenue')
/****** Object: Table [dbo].[RAW_Financial_expense_test] Script Date: 01/09/2013 18:04:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[RAW_Financial_expense_test](
[year_time] [varchar](100) NULL,
[district_code] [varchar](150) NULL,
[district_name] [varchar](150) NULL,
[FUND_CODE] [varchar](150) NULL,
[fund_description] [varchar](150) NULL,
[fund_type] [varchar](150) NULL,
[source_data] [varchar](250) NULL,
[source_state] [varchar](100) NULL,
[function_code] [varchar](150) NULL,
[function_description] [varchar](150) NULL,
[source_code] [varchar](100) NULL,
[source_description] [varchar](150) NULL,
[receipt_code] [varchar](100) NULL,
[receipt_description] [varchar](150) NULL,
[object_code] [varchar](100) NULL,
[object_description] [varchar](150) NULL,
[begin_balance] [varchar](100) NULL,
[end_balance] [varchar](100) NULL,
[actual] [varchar](100) NULL,
[budget] [varchar](100) NULL,
[report_type] [varchar](5) NULL,
[account_type_code] [varchar](5) NULL,
[account_type_desc] [varchar](50) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
INSERT [dbo].[RAW_Financial_expense_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Expenditure_Folders\FY07_exp.txt', N'OH', N'1140', N'Alternative School', NULL, NULL, NULL, NULL, N'412', N'Instructional Improvement Services:', NULL, NULL, NULL, NULL, NULL, N'E', N'expense')
INSERT [dbo].[RAW_Financial_expense_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Expenditure_Folders\FY07_exp.txt', N'OH', N'1140', N'Alternative School', NULL, NULL, NULL, NULL, N'419', N'Other Professional and Technical Services:', NULL, NULL, NULL, NULL, NULL, N'E', N'expense')
INSERT [dbo].[RAW_Financial_expense_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Expenditure_Folders\FY07_exp.txt', N'OH', N'1140', N'Alternative School', NULL, NULL, NULL, NULL, N'425', N'Early Childhood Education', NULL, NULL, NULL, NULL, NULL, N'E', N'expense')
INSERT [dbo].[RAW_Financial_expense_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Expenditure_Folders\FY07_exp.txt', N'OH', N'1140', N'Alternative School', NULL, NULL, NULL, NULL, N'432', N'Management Information System', NULL, NULL, NULL, NULL, NULL, N'E', N'expense')
INSERT [dbo].[RAW_Financial_expense_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Expenditure_Folders\FY07_exp.txt', N'OH', N'1140', N'Alternative School', NULL, NULL, NULL, NULL, N'433', N'Non-Certificated Travel Reimbursement:', NULL, NULL, NULL, NULL, NULL, N'E', N'expense')
INSERT [dbo].[RAW_Financial_expense_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Expenditure_Folders\FY07_exp.txt', N'OH', N'1140', N'Alternative School', NULL, NULL, NULL, NULL, N'441', N'Telephone Service:', NULL, NULL, NULL, NULL, NULL, N'E', N'expense')
INSERT [dbo].[RAW_Financial_expense_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Expenditure_Folders\FY07_exp.txt', N'OH', N'1140', N'Alternative School', NULL, NULL, NULL, NULL, N'443', N'Summer School Remediation', NULL, NULL, NULL, NULL, NULL, N'E', N'expense')
INSERT [dbo].[RAW_Financial_expense_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Expenditure_Folders\FY07_exp.txt', N'OH', N'1140', N'Alternative School', NULL, NULL, NULL, NULL, N'449', N'Other Communication Services:', NULL, NULL, NULL, NULL, NULL, N'E', N'expense')
INSERT [dbo].[RAW_Financial_expense_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Expenditure_Folders\FY07_exp.txt', N'OH', N'1140', N'Alternative School', NULL, NULL, NULL, NULL, N'461', N'Printing and Binding:', NULL, NULL, NULL, NULL, NULL, N'E', N'expense')
INSERT [dbo].[RAW_Financial_expense_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Expenditure_Folders\FY07_exp.txt', N'OH', N'1140', N'Alternative School', NULL, NULL, NULL, NULL, N'469', N'Other Craft and Trade Services:', NULL, NULL, NULL, NULL, NULL, N'E', N'expense')
/****** Object: Table [dbo].[RAW_Financial_balancesheet_test] Script Date: 01/09/2013 18:04:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[RAW_Financial_balancesheet_test](
[year_time] [varchar](100) NULL,
[district_code] [varchar](150) NULL,
[district_name] [varchar](150) NULL,
[FUND_CODE] [varchar](150) NULL,
[fund_description] [varchar](150) NULL,
[fund_type] [varchar](150) NULL,
[source_data] [varchar](250) NULL,
[source_state] [varchar](100) NULL,
[function_code] [varchar](150) NULL,
[function_description] [varchar](150) NULL,
[source_code] [varchar](100) NULL,
[source_description] [varchar](150) NULL,
[receipt_code] [varchar](100) NULL,
[receipt_description] [varchar](150) NULL,
[object_code] [varchar](100) NULL,
[object_description] [varchar](150) NULL,
[begin_balance] [varchar](100) NULL,
[end_balance] [varchar](100) NULL,
[actual] [varchar](100) NULL,
[budget] [varchar](100) NULL,
[report_type] [varchar](5) NULL,
[account_type_code] [varchar](5) NULL,
[account_type_desc] [varchar](50) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
INSERT [dbo].[RAW_Financial_balancesheet_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Cash_Records\FY07_Cash_Record.txt', N'OH', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'206891.77', N'764207', NULL, NULL, N'A', NULL, NULL)
INSERT [dbo].[RAW_Financial_balancesheet_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'006', N'Food Services ', N'Special Revenue Fund/Permanent fund/Private Purpose fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Cash_Records\FY07_Cash_Record.txt', N'OH', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'0', N'-13522.95', NULL, NULL, N'A', NULL, NULL)
INSERT [dbo].[RAW_Financial_balancesheet_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'007', N'Special Trust ', N'Special Revenue Fund/Private Purpose fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Cash_Records\FY07_Cash_Record.txt', N'OH', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'424.65', N'494.65', NULL, NULL, N'A', NULL, NULL)
INSERT [dbo].[RAW_Financial_balancesheet_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'007', N'Special Trust ', N'Special Revenue Fund/Private Purpose fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Cash_Records\FY07_Cash_Record.txt', N'OH', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'1354.86', N'1047.82', NULL, NULL, N'A', NULL, NULL)
INSERT [dbo].[RAW_Financial_balancesheet_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'007', N'Special Trust ', N'Special Revenue Fund/Private Purpose fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Cash_Records\FY07_Cash_Record.txt', N'OH', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'0', N'2500', NULL, NULL, N'A', NULL, NULL)
INSERT [dbo].[RAW_Financial_balancesheet_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'007', N'Special Trust ', N'Special Revenue Fund/Private Purpose fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Cash_Records\FY07_Cash_Record.txt', N'OH', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'0', N'485.88', NULL, NULL, N'A', NULL, NULL)
INSERT [dbo].[RAW_Financial_balancesheet_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'007', N'Special Trust ', N'Special Revenue Fund/Private Purpose fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Cash_Records\FY07_Cash_Record.txt', N'OH', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'0', N'17423.76', NULL, NULL, N'A', NULL, NULL)
INSERT [dbo].[RAW_Financial_balancesheet_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'018', N'Public School Support', N'Special Revenue Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Cash_Records\FY07_Cash_Record.txt', N'OH', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'30', N'30', NULL, NULL, N'A', NULL, NULL)
INSERT [dbo].[RAW_Financial_balancesheet_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'019', N'Other Grants', N'Enterprise fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Cash_Records\FY07_Cash_Record.txt', N'OH', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'38737.6', N'38737.6', NULL, NULL, N'A', NULL, NULL)
INSERT [dbo].[RAW_Financial_balancesheet_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'019', N'Other Grants', N'Enterprise fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Cash_Records\FY07_Cash_Record.txt', N'OH', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'1279.5', N'585.1', NULL, NULL, N'A', NULL, NULL)

Post #1405082
Posted Wednesday, January 9, 2013 8:42 PM


SSC-Dedicated

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

Group: General Forum Members
Last Login: Yesterday @ 11:19 PM
Points: 36,724, Visits: 31,173
What's the PK of each of those tables?

--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1405144
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse