Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL query help- Column headers and rows frm tables

Author  Topic 

vsmeruga
Starting Member

3 Posts

Posted - 2014-12-16 : 00:47:49
Hi gurus

I need help to write a sql statement to retrieve column headers and rows from 2 different tables.

eg:

row1: EMP column list, tag: emp
row2: DEPT column list, tag: Dept
row3: EMP columns data
row4: DEPT columns data

and the data sorted by deptno column
Eg:
EMP, Deptno, empno, ename, age, ...,
DEPT, Deptno, ename, loc
EMP, 10, 7548, Justin, 43,....
DEPT, 10, marketing, california
EMP, 20, 7345, Carol,26,....
DEPT, 20, finance, New York
EMP, ....
DEPT,...
.....
......

your our help on this is much appreciated.


Thanks

sz1
Aged Yak Warrior

555 Posts

Posted - 2014-12-16 : 10:19:14
What do you mean?
FROM TABLE1
row1: EMP column list, tag: emp
row2: DEPT column list, tag: Dept

FROM TABLE2
row3: EMP columns data
row4: DEPT columns data

4 columns? or a merged 2 column return.

We are the creators of our own reality!
Go to Top of Page

vsmeruga
Starting Member

3 Posts

Posted - 2014-12-17 : 11:48:58
Data,Tablename,ColumsList:eg: 10 rows shown below and ordered based on Acct_number

--------------------------------------

Row1,CASH,ACCT_NUMBER,AMOUNT,DEBIT_CREDIT_FLAG,ENTITY,BUSINESS_DATE,CURRENCY,REFERENCE,TRADE_TYPE,SUB ACC CODE

Row2,BALANCE,ACCT_NUMBER,OPENING_BALANCE,CLOSING_BALANCE,CLOSING_BAL_DEBIT_CREDIT_FLAG,BUSINESS_DATE,CURRENCY

Row3,CASH,10,500,CR,ABC,12/12/2014,USD,INTL,,US05

Row4,CASH,10,1000,DR,DEF,12/12/2014,USD,DOM,,US07

Row5,CASH,10,75,DR,XYZ,12/12/2014,USD,DOM,,US05

Row6,BALANCE,10,500,750,DR,12/12/2014,USD

Row7,CASH,20,500,CR,ABC,12/12/2014,USD,INTL,,US05

Row8,CASH,20,1000,DR,DEF,12/12/2014,USD,DOM,,US07

Row9,CASH,20,75,DR,XYZ,12/12/2014,USD,DOM,,US05

Row10,BALANCE,20,500,750,DR,12/12/2014,USD



Thanks
Go to Top of Page

vsmeruga
Starting Member

3 Posts

Posted - 2014-12-17 : 11:49:42
Cash and balance tables does not have same number of fields
Go to Top of Page
   

- Advertisement -