SQL UNION - illogical results

I have an interesting problem with UNION in SQL. My Statement is of this form: with tab as ( (select FldA, FldB From Table1A inner join Table1B on Field1A=Field1B) UNION (select FldA, FldB From Table2A inner join Table2B on Field2A=Field2B) ) select

SQL Count / sum multiple columns

I want to use count/ sum multiple fields in a single query sample data and desired result is as listed below: MemID claimNum ItemID PaidAmt 123 1234 4 5 123 2309 4 5 123 1209 4 5 123 1209 8 2.2 123 1210 8 2.2 Desired result MemID count(claimNum) coun

Complicated SQL while loop

I am trying to create a while loop in SQL and it seems kind of complex. Here's what I need it to achieve: Iterate through a single VARCHAR string (ex. '123') If the nth character is in an even position in the string (ex. 2nd, 4th .... letter in the s

SQL / ORA-00933 The SQL command is not successfully completed

I'm executing the following query: select count(*),ACTION_DATE from SUMMARY group by ACTION_DATE where NUM_ACTIONS=500; which is giving me ORA-00933 SQL Command not properly ended and I'm not sure why. SUMMARY is the table, ACTION_DATE and NUM_ACTION

Oracle numeric type that starts with 0

Which I have to use numeric data type(if numeric) in Oracle database, if i will store in that column the values which start with 0. For example 000, 0001, 02.That isn't numeric though. In numeric speak 00001 = 0001 = 001 = 01 = 1. They are all the sa

Get data between two dates with the unknown date format

date format: init(11) date column value: 1421382119 I have managed to get the dates from the table. $sqllast = $Db1->query("SELECT * FROM table"); while($row = $Db1->fetch_array($sqllast)) { $date1 = date('Y-m-d', $row['create']); echo &qu

Multiple where SQL Server clauses

I'm writing this query to check for duplicates, but can't get multiple wheres to work. Syntax error near "," is what I get. private static bool duplicate(Dictionary<TableKey, string> entry) { SqlConnection connection = new SqlConnection(Co

Response.Redirect does not work on a recorded event

I am creating a SignIn page with Login control. I want page to be redirect to another page once it got authenticated. But it redirecting me to home page.(home.aspx). Strange. Please advise. <asp:Login ID="Login1" runat="server" OnAu

Separation of Clock In and Clock Out data stored in a column

I am having a few issues with finding a solution to separate the date and times in which users have clocked in and clocked out of the current system. So far the table looks like this: 10412 Users Name 01/11/2012 07:12 10412 Users Name 01/11/2012 17.1

UDF function to search for files in SQL Server

This question is an exact duplicate of: Stored function to search files in SQL Server [closed] 2 answers Here is my case, I have a PRODUCTS table create table PRODUCTS ( ID_PRODUCTS CHAR(10) primary key not null, NAME CHAR(30), PRICE INTEGER ) Then I

Generating an archive list for a blog in Laravel

I am trying to generate an archive list for blog articles. The archive list should display year and date in reverse chronological order as follows: 2013 (21) - May (2) - April (3) - March (5) - February (1) - January (10) 2012 (10) - December (6) - N

PL / SQL Function / Package Problem

I am trying to create a package with four functions. Each function will add a set of numbers and subtract one from the total. I have been having lots of trouble getting the syntax correct. The functions below work on their own, and i try calling the

How do I create a relationship in Excel for multiple columns?

I'm trying to create a relationship between two tables in powerpivot. However, my tables don't have any keys. What I would like to do is create a SQL-Unique-Constraint-like relationship, which is based upon multiple values combined, being the key. Fo

SQL import data - Insert only if it does not exist

I am using SQL server management tool 2008 to import data to the web host database. I have tables with primary keys. (Id for each row) Now I can import data normally. But when I am importing data for the second time..I need to make sure only those ro

Design of the data cube: measurement difficult to aggregate

I'm in the process of designing the fact table for a data cube, and I have a measure which I don't really know how to correctly aggregate. The following SQL code will create a small sample fact table and dimension table: create table FactTable ( ID i

SQLite: ResultSet Returns SQLException

I have the following database ShorthandText textid | text -------------------------- 1 | just a test 2 | just another test I am using the following code to try return the two Strings in the text column public List<String> executeSQLWithMulipleReturn

Get the date that follows two days ago

I have a problem that i have been whacking my head over. No matter what day of the week it is I need the date thats 2 mondays ago. For example, if today is tuesday I need the monday before previous. I am using MS access to do this.I think you can use

A counting problem

I have a table with columns user_id, time_stamp and activity which I use for recoding user actions for an audit trail. How can I COUNT the number of unique user_id where time_stamp=0 when there might be multiple such rows, differing only in in the ac

Enter a stored procedure - canceled by the user

I am trying to debug a long stored procedure in Visual Studio 2008. I have followed all the steps on this link, but I still get the same error: 'Canceled by user' and it never hits the breakpoint. Visual Studio 2008 and SQL Server 2005 are running on

Is it possible to limit the results of an outer join?

I've got a scenario where I need to do a join across three tables. table #1 is a list of users table #2 contains users who have trait A table #3 contains users who have trait B If I want to find all the users who have trait A or trait B (in one simpl