| | |
sort data in ms access querie
![]() |
You can even add sort clause if u like to the same
TO SORT BY DATE
OR
TO SORT BY NAME AND DATE
TO SORT BY DATE
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
SELECT sNAME, sDATE, sTK FROM (SELECT Table1.name AS sNAME, Table1.date1 AS sDATE, Table1.tk AS sTK from Table1 UNION ALL SELECT Table2.add AS sNAME, Table2.date2 AS sDATE, Table2.tk2 AS sTK FROM Table2) ORDER BY sDATE
OR
TO SORT BY NAME AND DATE
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
SELECT sNAME, sDATE, sTK FROM (SELECT Table1.name AS sNAME, Table1.date1 AS sDATE, Table1.tk AS sTK from Table1 UNION ALL SELECT Table2.add AS sNAME, Table2.date2 AS sDATE, Table2.tk2 AS sTK FROM Table2) ORDER BY sNAME, sDATE
Regards
Shaik Akthar
Shaik Akthar
sorry dear I faced a few problem
1. here you gather 6 field in the query by 3 field. but i want the query have both 6 field of both table
I write code like you but it show a msg like
"The number of colums in two selected tables or queries of a union
query do not match"
I dont understand what I need to do. please help me.
1. here you gather 6 field in the query by 3 field. but i want the query have both 6 field of both table
I write code like you but it show a msg like
"The number of colums in two selected tables or queries of a union
query do not match"
I dont understand what I need to do. please help me.
when you write a union query u should see that both the queries have equal number of columns and that their datatypes are also same. If suppose one query has 6 and other query has 4 columns then query the remaining 2 columns with empty dummy data. for eg:
Here i assume that the Table1 having fields FatherName, Age and Place fields which are not there in Table2. hence i filled them with empty dummy fields only b'cos to match the total number of columns of both queries joined by the union query. This however being the SELECT query and is only a view, no changes are made to your actual database tables.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
SELECT sNAME, sDATE, sTK, sFATHER, sAGE, sPlace FROM (SELECT Table1.name AS sNAME, Table1.date1 AS sDATE, Table1.tk AS sTK, Table1.FatherName as sFATHER, Table1.Age as sAGE, Table1.Place as sPLACE from Table1 UNION ALL SELECT Table2.add AS sNAME, Table2.date2 AS sDATE, Table2.tk2 AS sTK, '' as sFATHER, 0 as sAGE, '' as sPLACE FROM Table2) ORDER BY sNAME, sDATE
Here i assume that the Table1 having fields FatherName, Age and Place fields which are not there in Table2. hence i filled them with empty dummy fields only b'cos to match the total number of columns of both queries joined by the union query. This however being the SELECT query and is only a view, no changes are made to your actual database tables.
Regards
Shaik Akthar
Shaik Akthar
•
•
Join Date: Aug 2009
Posts: 2
Reputation:
Solved Threads: 0
i try to execute your sql statment in sql query analyzer but it giving following error......
my query
SELECT project_code, ref, rdate, princ,
service [select TblRePayment.project_code,TblRePayment.ref,TblRePayment.rdate,TblRePayment.princ,TblRePayment.service FROM TblRePayment UNION ALL SELECT TblRePayment_re.project_code,TblRePayment_re.ref,TblRePayment_re.rdate,TblRePayment_re.princ,TblRePayment_re.service FROM TblRePayment_re]. AS [%$##@_Alias];
error
Server: Msg 103, Level 15, State 7, Line 2
The identifier that starts with 'select TblRePayment.project_code,TblRePayment.ref,TblRePayment.rdate,TblRePayment.princ,TblRePayment.service FROM TblRePayment ' is too long. Maximum length is 128.
Server: Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near '.'.
my query
SELECT project_code, ref, rdate, princ,
service [select TblRePayment.project_code,TblRePayment.ref,TblRePayment.rdate,TblRePayment.princ,TblRePayment.service FROM TblRePayment UNION ALL SELECT TblRePayment_re.project_code,TblRePayment_re.ref,TblRePayment_re.rdate,TblRePayment_re.princ,TblRePayment_re.service FROM TblRePayment_re]. AS [%$##@_Alias];
error
Server: Msg 103, Level 15, State 7, Line 2
The identifier that starts with 'select TblRePayment.project_code,TblRePayment.ref,TblRePayment.rdate,TblRePayment.princ,TblRePayment.service FROM TblRePayment ' is too long. Maximum length is 128.
Server: Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near '.'.
•
•
Join Date: Aug 2009
Posts: 2
Reputation:
Solved Threads: 0
i try to execute your sql statment in sql query analyzer but it giving following error......
my query
SELECT project_code, ref, rdate, princ,
service [select TblRePayment.project_code,TblRePayment.ref,TblRePayment.rdate,TblRePayment.princ,TblRePayment.service FROM TblRePayment UNION ALL SELECT TblRePayment_re.project_code,TblRePayment_re.ref,TblRePayment_re.rdate,TblRePayment_re.princ,TblRePayment_re.service FROM TblRePayment_re]. AS [%$##@_Alias];
error
Server: Msg 103, Level 15, State 7, Line 2
The identifier that starts with 'select TblRePayment.project_code,TblRePayment.ref,TblRePayment.rdate,TblRePayment.princ,TblRePayment.service FROM TblRePayment ' is too long. Maximum length is 128.
Server: Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near '.'.
plz. help me out
thanks
my query
SELECT project_code, ref, rdate, princ,
service [select TblRePayment.project_code,TblRePayment.ref,TblRePayment.rdate,TblRePayment.princ,TblRePayment.service FROM TblRePayment UNION ALL SELECT TblRePayment_re.project_code,TblRePayment_re.ref,TblRePayment_re.rdate,TblRePayment_re.princ,TblRePayment_re.service FROM TblRePayment_re]. AS [%$##@_Alias];
error
Server: Msg 103, Level 15, State 7, Line 2
The identifier that starts with 'select TblRePayment.project_code,TblRePayment.ref,TblRePayment.rdate,TblRePayment.princ,TblRePayment.service FROM TblRePayment ' is too long. Maximum length is 128.
Server: Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near '.'.
plz. help me out
thanks
![]() |
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Who has the database open?
- Next Thread: How to get mac address with input ip address
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





