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.
| Author |
Topic |
|
krishnet
Starting Member
29 Posts |
Posted - 2007-06-08 : 17:26:56
|
| Hi,I have the following tablesTable :Accountaccountid int identity,(p.k.)accountname varchar(20)not nullTable : MiscPaymiscid int identity,(p.k.)accountid int not null, (f.k.)storeid int not null,(f.k.)paymentdt datetime not null,payeename varchar(30) not null,paymode varchar(20) not null,bankname varchar(50),chqdt datetime,chqueno varchar(20),amt numeric(10, 2) not null,remarks varchar(50)not nullQUERY :SELECT '1', '' AS PAYMODE, accountname AS NAME, '' AS payeename, '' AS paymode, NULL AS storeid, NULL AS amt, NULL AS paymentdt FROM ACCOUNTWHERE accountid = 2UNIONSELECT '2', '' AS PAYMODE, '' AS NAME, payeename, paymode, storeid, amt, paymentdtFROM MiscPayWHERE accountid = 2 and paymode ='cash' and storeid=1ORDER BY 1, 2, 3What i want is the output as :On basis of paymentmode as cash and chequeOn basis of accountnameOrderby paymentdt and amt.I also want the summary total of the amt columnACCOUNTNAME| PAYMODE| PAYDATE| PAYEENAME |AMTExpenses |Cash11/11/2006| A| 300.0012/12/2006| B| 400.00------700.00ACCOUNTNAME |PAYMODE| PAYDATE| CHQNO |BANKNAME |PAYEENAME |AMTExpense |Credit1/1/2007 |56678| SBI |A |850.001/2/2007 |46575| SBI |B | 50.00 --------900.00thanxs... |
|
|
krishnet
Starting Member
29 Posts |
Posted - 2007-06-12 : 09:46:41
|
| Any solution ?? |
 |
|
|
|
|
|
|
|