Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all 13329 articles
Browse latest View live

SQL to group, classify and count each group

$
0
0
please look at the following data:


party_id item date
======================
3506814 cap 6/19/2014
3506814 cap 6/19/2014
3506814 shirt 6/19/2014
3507919 cap 6/19/2014
3507919 shoes 6/19/2014

for each row above, the buckets are for a given day, I want to classify each row according the rule below : basically loop over a window of data.

if a party bought 1 from each group below, then classify it as Both or else classify it as the item itself.

group a items (cap, whistle, scarf)
group b items (tshirt, trouser, shoes)

Sample output based from records above

output 1 (I guess I need to use

party_id item date category_grp
================================
3506814 cap 6/19/2014 both
3506814 cap 6/19/2014
3506814 shirt 6/19/2014
3507919 cap 6/19/2014 cap
3507919 shoes 6/19/2014 shoes

output 2 -- count of each category (I guess I need to use PIVOT for this)


date both cap shoes
=================================
6/19/2014 1
6/19/2014 1 1

Please help me with the above scenario. Also can we do conditional counting using count(case...) over(partition by...)

Thanks

Excel files on DVD

$
0
0
I have 3 EXcel files I want to put on a DVD, To access them I want a menu to show the 3 files and press a button to load them.
The dvd is to run on other windows computers
CAN ANY ONE HELP, I have done one with html but it only works on one computer.

Freedom Backup

$
0
0
I have a backup of a freedom database that they say is pervasive sql. it has .sqs, .obi, .sqt files. I have v11 on my computer. I need to restore the backup locally so I can take a look at the files.

How do I restore the backup?

v11 restore?

$
0
0
I receieved a backup for a v11 database(s). all of the files are .sqs, .obi, .sqt?

Script freezes during normal activation but not when debugging

$
0
0
I am experiencing a really strange behavior. I have a script that is activated via a button. I have records for 36 individuals and can run this report for each person when I select their record and press the button. Most of the time, the script executes perfectly; however, there are occasions when the script runs and it freezes up Brilliant Database and this is AFTER the script is complete. It does this only for certain individuals and it always freezes for these same people. When I select an individual where it has been freezing up on and debug the script manually through each line of script and it does not freeze anything... it just does it when I activate it normally through clicking on the button.

I have spent hours last night and today examining the records and everything is intact but I cannot find why Brilliant Database freezes during normal script execution and NOT when stepping through the script line by line. Has anyone else experienced this sort of odd behavior?

Need help with saving/editing a record using a form with a combo box

$
0
0
So this is what I'm trying to do:

I have a form that I need to use to add new clients to a table in my database, lets call it tblClients. On this form I have a combo box which, when selected, will drop down with the first and last names of all clients in tblClients, as well as their Client ID. Once you select a client from the drop down menu, it populates all of the fields in the form with that clients info (Client ID, fname, lname, address, phone number, etc. etc.). I need two other things on this form: one button that will save or modify whatever current record is currently pulled up, and one button that will start the process for entering a new client, so basically it would blank out all of the fields and fill the Client ID field with the current number +1.

As of right now I have the form made and the combo box works, in that I have 3 dummy clients in the tblClients and when I select each client from the combo box it will populate the fields on the form with the info. I'm using some simple VBA on the combo box such as

Me.FirstName = Me.cboBox.Column(1)

and that seems to all work, but the problem is trying to save/modify data to tblClients. The only record in the actual table that gets modified seems to be the first record. For example, if I pull up client with ID #3 and change his address or phone number, what happens when I click to save the changes it takes client ID #3 record, overrides it with client ID #1, and then client ID #3 is the same as client ID #1 except with the old information. I'm not quite sure why this is happening. Any ideas? Keep in mind that I would say I just have an intermediate knowledge of Access and VBA coding, although I'm pretty good at understanding syntax and figuring out how to modify code to adapt to what I need. I feel like I just kind of need a push in the right direction as to what to do here.

db2ckrst output problem

$
0
0
Hi all,

Environment: Db2 LUW 10.1 on RHEL 5.

I have taken online full, baseline full inc. backup and then delta backups.

But command db2ckrst is not showing as expected output. I am confused with that scenerio is given below:

online full backup:
[db2inst1@db2host ~]$ ls -lrt /home/db2inst1/onlinedb2backup/
total 245856
-rw------- 1 db2inst1 db2inst1 251752448 Jun 23 16:10 DBMSTC.0.db2inst1.DBPART000.20140623161012.001

online inc. full backups:
[db2inst1@db2host ~]$ ls -lrt /home/db2inst1//onlineincbackup/
total 491740
-rw------- 1 db2inst1 db2inst1 167845888 Jun 23 17:09 DBMSTC.0.db2inst1.DBPART000.20140623170508.001
-rw------- 1 db2inst1 db2inst1 167845888 Jun 23 17:37 DBMSTC.0.db2inst1.DBPART000.20140623173621.001
-rw------- 1 db2inst1 db2inst1 167845888 Jun 24 10:20 DBMSTC.0.db2inst1.DBPART000.20140624101934.001

online delta backups:
[db2inst1@db2host ~]$ ls -lrt /home/db2inst1/onlinedeltabackup
total 508124
-rw------- 1 db2inst1 db2inst1 184627200 Jun 24 10:50 DBMSTC.0.db2inst1.DBPART000.20140624104841.001
-rw------- 1 db2inst1 db2inst1 201408512 Jun 24 10:54 DBMSTC.0.db2inst1.DBPART000.20140624105258.001
-rw------- 1 db2inst1 db2inst1 134283264 Jun 25 15:02 DBMSTC.0.db2inst1.DBPART000.20140625150227.001

now the command: db2ckrst -d dbmstc -t 20140623173621

is giving output

Suggested restore order of images using timestamp 20140623173621 for
database dbmstc.
================================================== ==================
restore db dbmstc incremental taken at 20140623173621
restore db dbmstc incremental taken at 20140623161012
restore db dbmstc incremental taken at 20140623173621
================================================== ==================

why it is so ? why 20140623173621 is coming twice and no delta backup is listed ?

please suggest ?

regards
sumit

DB2 Slow Startup on RHEL


Access Problem Reading SQL Server Database

$
0
0
Front End: MS Access 2010
Back End: SQL Server 2008

I want to write in Access VBA code a routine that will add to the database an Employee table with a Skills table associated with it (one to many relationship). I have done this many times in Access but not in VBA. The add routine for Employee is complete. What I am having problems with is the Skills. For example to add the records:

zSQL = _
"INSERT INTO [dbo_Employee] " & _
"(employee, position)" & _
" VALUES(" & _
"'" & Remployee & "'" & _
", '" & Rposition & "')"

DoCmd.SetWarnings False
DoCmd.RunSQL zSQL

This adds the Employee. How do I add the Skills?

SkillID int <-- primary key
EmployeeID int <-- FK Skill to Employee
Skill varchar(50)
DateTaken datetime

Any help will be appreciated.

linked server sybase to sybase

$
0
0
hi!

i need to link one sybase server to other...

simple task: use into statement to "first" server a subselect to "second" server

i can't find it for myself...

so much trash in network, like sybase to oracle, oracle to sybase and so on

and this magic site SyBooks Online is very confused

can somebody help me?

PS:
Adaptive Server Enterprise/15.0.3/EBF 19671 ESD#4 ONE-OFF/P/Sun_svr4/OS 5.8/ase1503/2768/64-bit/FBO/Thu Nov 10 03:10:10 2011

from managers i have only Aqua Data Studio

data import

$
0
0
Hi,

I have old system on 10g and trying to move data from 10 g to 11GR2(11.2.0.3) on linux

I have created instance on 11G already

if i do full export of 10G database. (expdp system/XXXXXX full=y directory=sys_dmp dumpfile=full_db_expdp.dmp logfile=full_db_expdp.log)

and then import in to 11G can all the roles and users can come to 11G as well or i will have to create that seperately?

Thanks

Password expiration issue

$
0
0
I'm receiving an error message on DB2 9.7.0.7 running on AIX 7.1 and authenticating using QAS 4.0.3. If I log in to the database server and try to connect using "db2 connect to databasename user username using password" I get the following error message: SQL30082N Security processing failed with reason "1" ("PASSWORD EXPIRED").
SQLSTATE=08001. If I try to connect using "db2 connect to databasename" it works fine. I also get this error message trying to connect through any database utility on my local machine. My DBAUTH is set to OSAUTH and I feel like QAS is authenticating properly since I'm able to log into the server. Any ideas?

Access: Set parameter of existing query object in vba and display results in subform

$
0
0
Hi all,
I have an existing query object and I'd like to do the following with it in vba:
Get its date start and date end parameters from respective textboxes in the main form, then run it through button click and display the results in the subform of the mainform. The expected result of the query are those records that fall within the range of date start and date end parameters.

The subform is bound to the said query with the name qrySearchBills. The textboxes of which date parameters shall be taken from are txtStartDate and txtEndDate respectively.

Can you guys shade some light on me? This is my first post in this forum and I'd really appreciate your help.

sql error

$
0
0
Hi,

I am getting below error while selecting the rows from table in jcl


SQL ERROR DURING SQL STATEMENT OPEN , TABLE TBLNAME
SQLCODE = -904, ERROR: UNSUCCESSFUL EXECUTION CAUSED BY AN UNAVAILABLE RESOURCE. REASON 00C90084, TYPE OF
RESOURCE 00000100, AND RESOURCE NAME DB2-MANAGED SPACE WITHOUT SECONDARY ALLOCATION OR USER-MANAGED SPACE IN DSNDBD
SQLSTATE = 57011 SQLSTATE RETURN CODE
SQLERRP = DSNXRSOR SQL PROCEDURE DETECTING ERROR
SQLERRD = -115 13172746 0 13231826 -959250432 14090279 SQL DIA
SQLERRD = X'FFFFFF8D' X'00C9000A' X'00000000' X'00C9E6D2' X'C6D
INFORMATION

Can anyone say what error rearding that?
Thanks,

How should I define Color Columns for Products

$
0
0
Excuse my ignorance in understanding database structure, but I'm defining our product for a database with Excel and intend to upload them to a mySQL database. But I need your help with consolidation of attributes or keeping them unique based on each product types.

My issue is we sell multiple different types of products and one of the key attributes is COLOR. Lets say I sell a baseball (ID 1) that is white with red stitching, but I also sell tennis balls that are white (ID 2), blue (ID 3), and green (ID 4). How do I structure the columns and input the data.

Do I:
Sheet (all product)
id/color/stitch_Color
1/White/Red
2/white/"null"
3/blue/"null"
4/green/"null"

Or do I define them separately, and have two different spreadsheets and import them separately:
Sheet 1 (baseballs)
id/baseball_color/stitch_color
1/white/red

Sheet 2 (tennis balls)
id/tennis_ball_color/
2/white
3/blue
4/green

Thanks for you help.

Left Join, Null fields, and Conditional fields

$
0
0
Hello,

There are a lot of similar topics on this but none seem to address left joining a table based on fields conditional of specific values that I can find. I'm not sure how to get what I need.

In English, I need a list of users who have "active" shiptos assigned to their profile and anyone that doesn't have any and needs one. It's the status of the shiptos that are spinning me in a loop as some of them have assigned inactive shiptos.

Here's my query:
Code:

WITH tUsers (u_id, u_name) AS (
  VALUES
  (11, 'Bob')
  ,(12, 'Steve')
  ,(13, 'Joe')
), tUsersShiptos (us_id, us_u_id, us_s_id) AS (
  VALUES
  (21, 11, 31)
  ,(22, 11, 32)
  ,(23, 12, 32)
), tShiptos (s_id, s_name, s_status) AS (
  VALUES
  (31, 'st1', 'A') --Active
  ,(32, 'st2', 'D') --Deactive
) (
  SELECT u_name, s_name
  FROM tUsers
  LEFT OUTER JOIN tUsersShiptos ON u_id=us_u_id
  LEFT OUTER JOIN tShiptos ON us_s_id=s_id AND s_status='A'
) WITH UR

And Here's the result:
Code:

Bob        st1
Bob       
Steve       
Joe

I need to get rid of the 2nd Bob as he has an active shipto so the inactive shipto row doesn't need to show. I tried this query:
Code:

  SELECT u_name, s_name
  FROM tUsers
  LEFT OUTER JOIN tUsersShiptos ON u_id=us_u_id
  LEFT OUTER JOIN tShiptos ON us_s_id=s_id AND s_status='A'
  WHERE s_name IS NOT NULL

Which left me with this result:
Code:

Bob        st1
I still need Steve and Joe to show because they have either no shiptos or all inactive shiptos. It has to show that they need an active one. I want to avoid simply running two queries and UNIONing them together because I don't want to query the same tables more than once. So I tried this query:
Code:

  SELECT u_name, s_name, COUNT(s_id) OVER(PARTITION BY u_id) AS scount
  FROM tUsers
  LEFT OUTER JOIN tUsersShiptos ON u_id=us_u_id
  LEFT OUTER JOIN tShiptos ON us_s_id=s_id AND s_status='A'
  WHERE (s_name IS NOT NULL OR scount=0)

But it errs on "scount" in the WHERE clause.

The expected result is this:
Code:

Bob        st1
Steve
Joe

How can i achieve the expected result? Any help is appreciated. thanks,

Query error with date format

$
0
0
I am working on a database in php/mysql and have a table 'clientnotes' which has fields noteid, dateadded, addedby, note, clientcode. I want to see a simple table of all of the notes added for a specific client.

If I use the query:
$colname_rsNotes = "-1";
if (isset($_GET['clientcode'])) {
$colname_rsNotes = $_GET['clientcode'];
}
mysql_select_db($database_renmms, $renmms);
$query_rsNotes = sprintf("SELECT noteid, dateadded, addedby, note, clientcode FROM clientnotes WHERE clientcode = %s", GetSQLValueString($colname_rsNotes, "text"));
$rsNotes = mysql_query($query_rsNotes, $renmms) or die(mysql_error());
$row_rsNotes = mysql_fetch_assoc($rsNotes);
$totalRows_rsNotes = mysql_num_rows($rsNotes);

then it works fine. However, if I add into it some code to format the date as below:

$colname_rsNotes = "-1";
if (isset($_GET['clientcode'])) {
$colname_rsNotes = $_GET['clientcode'];
}
mysql_select_db($database_renmms, $renmms);
$query_rsNotes = sprintf("SELECT noteid, dateadded, addedby, note, clientcode, DATE_FORMAT(dateadded,'%D %M %Y') AS formattedDate FROM clientnotes WHERE clientcode = %s", GetSQLValueString($colname_rsNotes, "text"));
$rsNotes = mysql_query($query_rsNotes, $renmms) or die(mysql_error());
$row_rsNotes = mysql_fetch_assoc($rsNotes);
$totalRows_rsNotes = mysql_num_rows($rsNotes);

Then I get a blank page except for 'Query was empty'

What am I doing wrong?

Many thanks.

Checkbox Problem

$
0
0
Is there a way that I can make a checkbox that returns yes values when checked and both yes and no values when unchecked?

Want to see unchecked entries only

$
0
0
I am a novice so I need step by step instructions....Please.

I have a simple database where one group of people enter data into a form and another group run a report to extract that data and complete the action necessary based on the entries.

I have created a separate form which includes checkboxes so that when the necessary actions are completed they can be checked off.

In my query I have the criteria as Null...I don't know if this is correct.

My problem is when the report is run, it still shows all the entries, the ones showing completed with the check in the checkbox and also the ones that are still uncompleted and therefore not checked.

What I would like is for the report to only show the entries that have Not been completed/checked.

I will appreciate any assistance with this. I've been trying to figure it out by trial and error for days but am stumped.

Thanks
Tracy

An Interesting scroll bar problem

$
0
0
Hi I have a form with several tabs and several sub forms on them. On the main form I have some command buttons to generate reports. The main form has the scroll bar properties set to neither and when I open the form all is correct. See screen-1 attachment. When I go to any report the report screen opens the report is shown in print preview mode. When I close the report the main form is shown with both scroll bars see screen-2 attachment. If I close the main form and reopen it there are no scroll bars as intended. I have done some Google searches with no success. This may be that I am having a tough time trying to describe the problem in a Google search. Does any one have any ideas.:confused::confused:

Attached Files
File Type: doc Screen-1.doc (356.0 KB)
File Type: doc Screen-2.doc (349.5 KB)
Viewing all 13329 articles
Browse latest View live