Convert And Sql Query To Access
Sep 15, 2007
someone wrote this query for me in SQL and there is one part of it I don't understand can someone tell me how to convert this line for access? I don't know what || is
TO_NUMBER(SUBSTR(TO_CHAR(WE.mth_welfare),5,2) ||
SUBSTR(TO_CHAR(WE.mth_welfare),1,4)) an_mth_welfare
SELECT
WE.mth_welfare,
WE.id_case_welfare,
WE.id_case,
OB.id_member,
SUM(WE.amt_mtd_assist_expnd),
SUM(WE.amt_ltd_assist_expnd),
SUM(WE.amt_ltd_assist_recoup),
TO_NUMBER(SUBSTR(TO_CHAR(WE.mth_welfare),5,2) ||
SUBSTR(TO_CHAR(WE.mth_welfare),1,4)) an_mth_welfare
FROM noldba.welfare_balance_by_obligation WE, noldba.obligation OB
WHERE WE.id_case = OB.id_case
AND WE.seq_order = OB.seq_order
AND WE.seq_obligation = OB.seq_obligation
AND WE.mth_welfare <= 200708
AND WE.dt_END_validity = '31-DEC-9999'
AND WE.dt_end_validity = OB.dt_end_validity
AND OB.dt_beg_obligation = (SELECT MAX(c.dt_beg_obligation)
FROM noldba.obligation c
WHERE c.id_case = ob.id_Case
AND c.seq_order = ob.seq_order
AND c.seq_obligation = ob.seq_obligation
AND c.dt_end_validity = '31-DEC-9999')
GROUP BY WE.id_Case, OB.id_member, WE.id_case_welfare, WE.mth_welfare
ORDER BY WE.mth_welfare DESC,
WE.id_case DESC,
OB.id_member DESC;
View Replies
ADVERTISEMENT
Dec 18, 2007
I have this query which I use with a program called "Query Reporter" - it runs well and gives me the correct answers.
Select COUNT (b.case_id),
sum(a.amt_to_distribute) Held_amt,
iv_d_do_code,
cd_reason_status--HELD REASONS-DH-DIST,NX-NO OBL,XS-EXCESS OBL,MW-MANU WKR,HM-NO MHIS,CC-CLOSED
From vrcth a, vcase b
Where A.Cd_Status_Receipt = 'H'
And A.Dt_Distribute = '01-JAN-0001'
And A.Dt_End_Validity = '31-DEC-9999'
AND Not Exists (Select 1 from vrcth k -- Checking receipt is not backed out
where a.dt_batch = k.dt_batch
ANd a.no_batch = k.no_batch
And a.cd_source_batch = k.cd_source_batch
And a.seq_receipt = k.seq_receipt
And k.ind_backout = 'Y'
And k.dt_end_validity = '31-DEC-9999')
And ((trim(A.Id_Case) IS NOT NULL -- When receipt is case identified
AND A.Id_case = b.case_id )
Or
( trim(A.Id_Case) IS NULL -- When receipt is payor identified
ANd b.case_id = (Select Min(y.case_id) from vcase Y, vcmem Z
Where A.Id_Payor = z.member_id
And z.relation_code IN ('A','P')
And z.case_id = y.case_id )
))
group by iv_d_do_code,
cd_reason_status
order by iv_d_do_code;
What I want to do is to rewrite the query in Access and get the same results. This is what I came up with which is returning nothing. Would someone please give the two of them a look and tell me what I'm missing the in Access query. Thanks
SELECT Count(b.CASE_ID) AS CountOfCASE_ID, Sum(a.AMT_TO_DISTRIBUTE) AS Held_amt, b.IV_D_DO_CODE, a.CD_REASON_STATUS
FROM NOLDBA_RECEIPT AS a, NOLDBA_INT_CASE_STATUS AS b
WHERE (((Trim([a].[id_case])) Is Not Null) AND ((a.ID_CASE)=[b].[case_id]) AND ((a.CD_STATUS_RECEIPT)='H') AND ((a.DT_DISTRIBUTE)=#1/1/2001#) AND ((a.DT_END_VALIDITY)=#12/31/9999#) AND ((Exists (select 1 from NOLDBA_RECEIPT k
where a.dt_batch=k.dt_batch
and a.no_batch=k.no_batch
and a.cd_source_batch=k.cd_source_batch
and a.seq_receipt=k.seq_receipt
and k.ind_backout ='Y'
and k.dt_end_validity =#12/31/9999#))=False)) OR (((Trim([a].[id_case])) Is Null) AND ((a.CD_STATUS_RECEIPT)='H') AND ((a.DT_DISTRIBUTE)=#1/1/2001#) AND ((a.DT_END_VALIDITY)=#12/31/9999#) AND ((Exists (select 1 from NOLDBA_RECEIPT k
where a.dt_batch=k.dt_batch
and a.no_batch=k.no_batch
and a.cd_source_batch=k.cd_source_batch
and a.seq_receipt=k.seq_receipt
and k.ind_backout ='Y'
and k.dt_end_validity =#12/31/9999#))=False) AND ((b.CASE_ID)=(select min (y.case_id) from NOLDBA_INT_CASE_STATUS Y, NOLDBA_INT_CASE_MEMBER Z
WHERE A.ID_PAYOR=Z.MEMBER_ID
AND Z.RELATION_CODE IN ('A','P')
AND Z.CASE_ID=Y.CASE_ID)))
GROUP BY b.IV_D_DO_CODE, a.CD_REASON_STATUS
ORDER BY b.IV_D_DO_CODE;
View 3 Replies
View Related
Jul 12, 2005
I just started working for a company the other week and they threw this query onto my lap with an unrealistic deadline. My programming experience is primarily in VB6, so I am not completely familiar with coding Access queries.
I was given code that was written for SQL, and the programmer that came up with it is unfamiliar with Access, so I am stuck trying to decipher this. If anyone could help me out, I would greatly appreciate it, as I am thoroughly confused and don't know where to begin. Here is the programmer's original code:
while exists(select top 1 accNum from NoteFile where patindex('%' + char(10) + '%',dbtrref) > 0)
begin
--Insert note into table
insert into #TL19Note(AcctNumber, Note)
select accNum, (case when patindex('%' + char(10) + '%',
dbtrref) <= 0 then dbtrref else left(dbtrref,patindex('%' + char(10) +
'%',dbtrref)) end)
from NoteFile
--Delete note from Note String
update NoteFile
set dbtrref = right(dbtrref,len(dbtrref)-len(left(dbtrref,patindex('%' + char(10) + '%',dbtrref))))
where len(dbtrref)-len(left(dbtrref,patindex('%' + char(10) +'%',dbtrref))) > 0
--Delete rows with no more notes
delete from NoteFile
where len(dbtrref)-len(left(dbtrref,patindex('%' + char(10) +'%',dbtrref))) <= 0 or patindex('%' +char(10) + '%',dbtrref) <= 0
end
--Eliminates any that are CRLR or just spaces
delete from #TL19Note
where len(Note) < 10
--Update the date
update #TL19Note
set NoteDate =left(Note,patindex('% %',Note)-1),
Note = right(Note,len(Note)-patindex('% %',Note))
--No '@' means no time?
update #TL19Note
set NoteTime = '0000'
where left(Note,1) <> '@'
--delete the '@' - we know which ones have it because NoteTime is null
update #TL19Note
set Note = right(Note,len(Note)-patindex('% %',Note))
where left(Note,1) = '@'
--Update NoteTime, take time out of note
update #TL19Note
set NoteTime = left(Note,2) + substring(note,4,2),
Note = right(Note,len(Note)-patindex('% %',Note))
View 6 Replies
View Related
Oct 21, 2005
Hi folks,
I have a query which pulls together several other queries. It works fine in Access but I also need it to work on a MS SQL server.
the SQL is as follows;
SELECT Client.ClientName, Entity.EntityName, IIf([101].[ProductID] IS NULL, [-], [X]) AS TA, IIf([301].[ProductID] IS NULL, [-], [X]) AS TR, IIf([302].[ProductID] IS NULL,
[-], [X]) AS CU, IIf([304].[ProductID] IS NULL, [-], [X]) AS TC, IIf([502].[ProductID] IS NULL, [-], [X]) AS FA, IIf([503].[ProductID] IS NULL, [-], [X]) AS MO
FROM Client LEFT JOIN
Entity ON Client.ClientID = Entity.ClientID LEFT JOIN
VIEW_PROD301 AS 301 ON Entity.EntityID = [301].EntityID LEFT JOIN
VIEW_PROD302 AS 302 ON Entity.EntityID = [302].EntityID LEFT JOIN
VIEW_PROD304 AS 304 ON Entity.EntityID = [304].EntityID LEFT JOIN
VIEW_PROD502 AS 502 ON Entity.EntityID = [502].EntityID LEFT JOIN
VIEW_PROD503 AS 503 ON Entity.EntityID = [503].EntityID LEFT JOIN
VIEW_PROD101 AS 101 ON Entity.EntityID = [101].EntityID;
The problem seems to be with the iif statement.
Any ideas how I can gt around this?
Thanks,
Dave
View 3 Replies
View Related
Oct 22, 2007
Can anyone help me convert this pivot query to work in sql server please?
I'll love you forever if you help me please :pTRANSFORM Count(Employees.MaritalStatus) AS MaritalStatusCount
SELECT Employees.MaritalStatus
FROM Employees INNER JOIN Offices ON Employees.OfficeId = Offices.officeId
WHERE ((Not (Employees.MaritalStatus) Is Null))
GROUP BY Employees.MaritalStatus
PIVOT Offices.officeLocation;
View 2 Replies
View Related
Feb 12, 2015
how to convert number date to text date.
Ex. Date field: 02/12/2015
convert into:
Month field
February
Day Field
12
Year
2015
View 3 Replies
View Related
Nov 10, 2014
I am in the process of building a new database in SQL to replace my MS Access database. However, I will continue to use the Access forms, queries, and reports. The new tables will house much of the same data. In multiple tables I have hyperlinks that were created and added in the original Access tables. To import these hyperlinks into the new SQL tables I have converted them to 'Long Text' before exporting, thus changing them into strings.
For example:
Hyperlink - Email - Add Additional Mailbox to Outlook (2010) has been changed to:
Email - Add Additional Mailbox to Outlook (2010)#ServernameServerfolderDocumentationRea dy to GoOutlook TemplatesEmail - Add Additional Mailbox to Outlook (2010).oft#
The obvious issue that I am running into is that after the SQL database table has been linked to the Access database it still displays the entire string when I open the table. The form has a textbox and search button that is used as a search function. This runs a query that returns all "search results" for the desired information. Is there a way that the query can convert the string back into a hyperlink so that the query displays just Email - Add Additional Mailbox to Outlook (2010) as a hyperlink and not the entire string?
View 1 Replies
View Related
Mar 12, 2007
I have made this query in ms sql it works fine as per my needs iam getting the values but this doesn work in ms access 2002 can someone work this out its lil urgent tested out a lot of things but better to give the best people's n get their knowledge...
SELECT wc.windowsname FROM windowsconductivity as wc join constructiondetailes as cd on wc.windowsid=cd.materialid join uvalueconstruction as uc on uc.constructionid=cd.constructionid join projectmasterwindows as pmw on pmw.windowconstruction=uc.constructionname WHERE pmw.projectname='new8thmarch07' and pmw.windowconstruction='new8thmarch' and uc.constructiontype='windows' order by cd.constructiondetailsid
thanks aton...
View 7 Replies
View Related
Sep 27, 2006
Hi,
A few years ago I’ve made an access database on access 2000. The problem is that now I’ve installed the office 2003, and I can’t make the database work properly.
At first says that are missing those files: “tshoot.ocx”, “msioff9.ocx” and “msowc.dll”; so, I’ve copy them from another computer using office 2000 and now only complains about “msioff9.ocx” saying that my database contains a reference incomplete to it.
Is there no other way to convert my database do work properly with access 2003? What can I do?
Regards
View 2 Replies
View Related
Feb 16, 2008
Hello
It been a while since i have been on the forum. I developed a database last year and since then i have moved to a MAC.
I would like to know if there is a quick and easy way of converting a database to application which works on any PC or MAC which does not have access?
View 2 Replies
View Related
Mar 11, 2005
Can anyone tell me the best and easiest way to convert an
existing ms access database to run on the web.
I am just a beginner at this so please tell me in simple terms.
thanks
View 1 Replies
View Related
Dec 15, 2011
select Saler, Model, Price, DDate
from DB_Table where DDate in
(select max(DDate) from DB_Table where Valid = 'ok' group by Saler, Model)
How can I make it work in ms access 2007? I am trying to get valid (ok) price for Saler-Model group at max date.
View 4 Replies
View Related
Aug 24, 2005
It's not letting me open it since i did it in 2003, and im trying to open it now at home in 2000.
I'd really appreciate if anyone can help me convert it and then attach it...thanks :o
View 3 Replies
View Related
Jan 22, 2006
Hello everyone
I’m trying to find a way to convert a UNIX timestamp to the standers universal timestamp. At this point I can’t even make sense of the UNIX time stamping system.
I would like to be able to use Microsoft access to do the conversion.
Does anyone one a why to convert the UNIX timestamp into a MMDDYY formatted time. Any help would be greatly appreciated
Thanks
Corey
View 1 Replies
View Related
Dec 29, 2006
I have a request to convert a Microsoft Access 2000 database from english to spanish. Can this be done easily?
View 1 Replies
View Related
Dec 29, 2007
all my access 2003 project stoped working. i have massage that missing file DTE.OLB.
View 2 Replies
View Related
Feb 14, 2008
I have an excel worksheet with the following formula
=IF(b40<50000,b40*0%,IF(b40<100000,b40*2.5%,b40*5%))
and I would like to convert it for use in access.
I came up with the following:
=iif([TOTAL]<50000,[TOTAL]*0%,IIF([TOTAL]<100000,[TOTAL]*2.5%,[TOTAL]*5%))
I get the following error: "The expression you entered contains invalid syntax.
You omitted an operand or operator, you entered an invalid character or comma, or you entered text without surrounding it with quotation marks."
I am probably missing something very simple here, but I have been unable to come up with a solution.
Any help would be greatly appreciated.
Regards,
Michael
View 3 Replies
View Related
Feb 11, 2014
I have a sql server query that I need to use in access 2003 but I can not figure out how to convert the "not in" part of the query. Here is the sql server query
Select * from accounts where beg_date between '1/1/2013' and '12/31/2013' and cast(acctNo,integer) in (2,3,4,5,7,12,20) and acct_type not in ('Individual','User','Viewer')
I can not find how to do the "not in" in access sql.
View 7 Replies
View Related
Apr 3, 2006
I have a client that has a access 97 mdb file as a backend and access 97 mde front end.
The problem is that they don't have the mdb file for the front end and they want me to convert it to 2000.
Is there software that can convert the 97 mde file to 2000 mde/mdb? If I try to import the queries, reports and forms it only allows me to import the queries.
View 1 Replies
View Related
May 30, 2006
Hello all.
I have a client with an Access 97 database and they have recently upgraded to Access 2003.
When I try to convert the database using the "Convert database" tool in Access 2003 it comes up with an error saying "There is no field named 'BaseRowLineage' in table 'MSysTombstone'"
The table MSysTombstone doesn't even seem to exist in the database when I look.
I have searched all over the net and this forum and can't seem to find an answer.
I am new to this so please forgive me if it something simple.
Any suggestions would be greatly appreciated.
Thanks for you time.
View 8 Replies
View Related
Aug 20, 2013
Creating a recordset from an Access table
Copy that recordset into a Variant variable, similar to a matrix
Run a Heuristic Algorithm on the matrix to populate values
Delete * from the orginal Access table
Input new data into the Original Access table by looping through matrix with an INSERT INTO statement.
This method works but I do not like the loop in step 5 as I am calling an INSERT INTO statement 800+ times and can be slow. Any way to view the variant as a whole and not have to loop through the entire matrix. Maybe possibly converting the variant to an Access tabledef.
View 2 Replies
View Related
Jul 7, 2015
I am importing a table from a Clarion TPS database which stores several types of data in a "IDVAL" field. The field next to it, "LBLNUM" defines what the data type is. This creates a problem, as IDVAL is a text field, which means all data stored in it (no matter what the type) is then stored as text. This includes date fields. Since they are stored as text, they end up as 5 digit serial dates, similar to how excel handles dates (with each day after 1/1/1900 being +1).
So I have a union query which derives all the values stored in IDVAL for each unique record. My query which creates my export combines this data with several calculated fields to create my final export.
Everything looks great on this final export except for my date fields, which are all 5 digit numbers (like 77945).
I have been searching for a date function that will format this back to a standard date, however I have yet to find anything that works. Is there no way to format a 5 digit serial date back to a standard date within access by using a function? Every answer I find says to redefine the table to a date field, however I don't have this option since the field in question stores a lot more than just dates.
View 3 Replies
View Related
Oct 21, 2013
How can I convert a web Access file to desktop aplication? I've created it from a model from Office.com, but I need create code in vba and it don't permit.
The use of file is only in desktop.
View 3 Replies
View Related
Feb 1, 2013
I have small program in access database which contains about 100 cca tables, querys, forms, macros in total. Customer which both program from me, wants me to enable him to access this program not just from work, it wants to access it from home or when he is on business trip from hotel etc.
I am little confused how to achieve this and what are my options? I assume I have to set by database somewhere on server and so my customer could access it any time? Do I have to upsize access database to SQL express or similar?
Also, one more important question: is it possible to "convert" access database into HTML code or similar so it could be accessed via web browser without need to install microsoft access and with freedom that it can be opened from any type of PC OS (Linux, Mac etc)?
View 14 Replies
View Related
Oct 9, 2014
Select * from Table where CDate(CStr(Nz(AnnouncementDate,0))) >=CDate(10-10-2014) and CDate(CStr(Nz(AnnouncementDate,0))) <= CDate(01-10-2014);
Here AnnouncementDate Column is Short Text
It gives me a type mismatch error..
View 3 Replies
View Related
Aug 7, 2015
I have files that have extension of TSV which are text files but viewable in exel. I figured out a way for the user to click on a button in Access which does the following
1. Run Macro in Excel: The macro prompts the user to select the TSV file. After selection, macro opens the employee.tsv file in the excel (with excel being invisible) and saves it as employee.xls
Code:
Sub SaveTSVtoXLS()
Dim myPath As String
Dim myString As Variant
Application.DisplayAlerts = False
With Application.FileDialog(msoFileDialogOpen)
[Code] .....
2. Imports the Excel file (employee.xls) into two tables: tblEmployee and tblDepartment using the following codes.
Code:
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, "qryDepartment", selectFile, True - 1, "A1:C2"
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, "qryEmployee", selectFile, True - 1, "A1:AE2"
Everything is working flawless except that the user has to select the file three times:
1 time for the tsv
2 times for the xls file
Is there a way that the user can select the file only once (tsv file) or at least only twice one of the tsv file and the other for the xls file?
View 8 Replies
View Related