sql

Access Left Join not working properly

In access I wrote this query: Select I.sysid, I.MemberNumber, I.Date, I.Distributer, F.MemberNumber as FMember, F.Date as FDate, I.Distributer as FDistributer From Initial as I Left Join Final as F ON I.MemberNumber=F.MemberNumber and I.Distributer=F.Distributer and I.Date>=F.Date-14 and I.Date<=F.Date+14; But the left joi...

Single out duplicates between two result sets

Hi, I'm having trouble with a query I'm trying to do. I'm trying to select values that come up in to result sets. I'm currently dealing with two queries: A) SELECT /*+ RULE */ pi.compressed_name, pi.phn, to_char(pi.date_of_birth , 'YYYY/MM/DD') as date_of_birth, gen.description as gender , to_char(pe.started_on , 'YYYY/MM/...

how to resolve 'htmlproxy release exception in RFT" or "httpproxy spy heap exception in RFT"

Am trying to reada a html table and iterating rows for specific column values and am getting the above exceptions .. any ideas ...

How to group by week of the year dates or day dates that start on Sundays in oracle 10?

Given a table: day_date (form of yyyy-mm-dd) column2 column3 I want to group the data by weeks, and the start of each week goes from Sunday to Saturday, but I want to display the day_date. I have looked around all over, and I'm rusty on my SQL. Thanks! ...

How to get number of users and blogs from Wordpress MU

I am currently maintaining some Wordpress MU installations ( v2.9.x ) I want to create a report ( outside of wordpress ) to count the number of users that I have, and the number of blogs that I have. Each blog gets it's own tables. I have 4 questions: First question, do you know of a plugin that does this already? I couldn't find o...

Best practice for naming SQL table columns

I will get involved in a big project and I would like to know which is, in your opinion, the best practice for naming SQL table columns. Lets say we have a products table. Which of the following naming will you prefer? id, name, description, photo, price or product_id, product_name, product_description, product_photo, product_pr...

sql server 2008: setting up a username properly in order to connect from VBA

i set up a login (reviewer) under security for SQL SERVER and under the specific database i set up a User (qcvalues_reviewer) that references this login i have tried all these different ways to login into the database from vba: 'cn.Open "Provider=SQLOLEDB;Data Source=hermes;Initial Catalog=test;User ID=qcvalues_reviewer; Password=921...

Mysql Query problem in searching record

Query: SELECT t1.id, t1.ads_city, t1.ads_title, t1.ads_description, t1.ads_type, t2.ads_activate, t2.postads_id, t2.ads_id FROM table_1 t1 JOIN nextpostads t2 ON t1.id = t2.postads_id WHERE MATCH(t1.ads_title,t1.ads_description) AGAINST ('LCD projector ,' IN BOOLEAN MODE) AND...

How can I add an additional field to an SQL Group By clause

I have the following MS-Access SQL Table:- NAME, SUBJECT, SCORE ..and I need to find the average score, highest score and the subject that the highest score was achieved against. I have managed to produce the following query but not sure how I can incorporate the SUBJECT field:- SELECT NAME, Avg(SCORE) AS AverageScore, MAX(SCORE) AS...

SQL to query by date dependencies

Hi, all. I have a table of patients which has the following columns: patient_id, obs_id, obs_date. Obs_id is the ID of a clinical observation (such as weight reading, blood pressure reading....etc), and obs_date is when that observation was taken. Each patient could have several readings on different dates...etc. Currently I have a quer...

Oracle sql query running for (almost) forever

An application of mine is trying to execute a count(*) query which returns after about 30 minutes. What's strange is that the query is very simple and the tables involved are large, but not gigantic (10,000 and 50,000 records). The query which takes 30 minutes is: select count(*) from RECORD r inner join GROUP g on g.GROUP_ID = r.G...

displaying Oracle table's column names

Is there a one-liner out there for this task? Note that I won't be using Oracle's SQL Plus. ...

Insert into Table select result set from stored procedure but column count is not same.

I need something like that which is of course not working. insert into Table1 ( Id, Value ) select Id, value from ( exec MySPReturning10Columns ) I wanted to populate Table1 from result set returned by MySPReturning10Columns. Here the SP is returning 10 columns and the table has just 2 columns. The following way works as long...

Best way to write union query when dealing with NULL and Empty String values

I have to write a query that performs a union between two tables with similar data. The results need to be distinct. The problem I have is that some fields that should be the same are not when it comes to empty values. Some are indicated as null, and some have empty string values. My question is, is there a better way to perform the...

How do I declare and assign a variable on a single line in SQL

Easy points. Quick search didn't tell me what I wanted. I want something like DECLARE myVariable nvarchar[MAX] = "hello world". Bonus points if you show me how to encode a quote in the string. eg. I want the string to read John said to Emily "Hey there Emily" my attempt would be DECLARE myVariable nvarchar[MAX] = "John said to ...

Optimal DB structure for a membership website with free and paid subscriptions

There is a regular Users (UserID, UserName, Email, Password) table which handles user registrations. Which other tables should be added in order to handle paid membership with 2 types of paid subscriptions - Monthly and Yearly. ...

str_to_date function in sql server?

MySQL has a function called STR_TO_DATE, that converts a string to date. Question: Is there a similar function in SQL Server? ...

How to replace CHAR(13) in DB varchar(6000)?

Using ColdFusion and Microsoft SQL we are exporting data to an Excel Spreadsheet using the cfx_excel plugin. The data contains a varchar(6000) which has CHAR(13)/line-breaks inputted in each entry. The line-breaks are appearing as square brackets every time the report is generated in Excel format. How would I go about removing the CHAR...

Oracle 'CONNECT BY' Syntax

This is an offshoot of the following question: http://stackoverflow.com/questions/3524604/single-out-duplicates-between-two-result-sets As by a comment in that questions, I'm trying to implement my query using Oracle's special 'CONNECT BY' syntax. I'm having trouble finding any (clear) information on how to implement the syntax in my ca...

SQL: one to many, select just one.

I am writing a small tool for managing the people registered to an association. I have a table USERS and a table CARDS. Each user can have more than one card (because cards expire). With one query I would like to extract ALL user information plus ALL card information only for the most recent card (field: ISSUEDATE). Here is a very bas...