query

SQL query need to get names where count(id) = 2

I have a table programparticipants, I am currently successfully querying the IDs where count(name) > 1. What I need now is to query the names that belong to those IDs where count(name) > 1. Can anyone help me please? Example, data result currently being returned: ID count(name) 1 2 3 4 4 ...

SQL query select data between two date fields

I am trying to select data from a table, using two date fields (startdate and enddate). With both date fields in the where clause no results are returned, with the startdate field taken out results are returned, what is going on? Can anyone help with this dilemna My code is: SELECT WPP.USERID, WPI.EMAIL, WPI.FI...

Designing an OO and Unit Test Friendly Query System

I'm working on an application that allows dentists to capture information about certain clinical activities. While the application is not highly customizable (no custom workflows or forms) it does offer some rudimentary customization capabilities; clients can choose to augment the predefined form fields with their own custom ones. Ther...

Sql query to alter table

I have two tables miusernames with columns where UserNamesID is the primary key for table miusernames.. UserNamesID UserName 1 senthil 2 robert and miemailids with columns where Emailid is the primary key for table miemailids .. Emailid UserNamesID 1 2 I forgot to create...

SQL Query to find ID's with as many hits as possible from an Array.

Hi everyone, English is not my native language so i'll try to explain as good as i can. I have a table with ID's in this table i also have account numbers. something like this: ID ACCOUNT 1 1000 1 1001 1 1002 2 1000 2 1001 3 1003 then i have an array (Posted from a form, like name="array[0]",name="array[1]",name="array[...

Select latest revision of each row in a table

I have table structures that include a composite primary key of id & revision where both are integers. I need a query that will return the latest revision of each row. If I understood this answer correctly then the following would have worked on an Oracle DB. SELECT Id, Title FROM ( SELECT Id, Revision, MAX(Revision) OVER (PARTITION BY...

Query to Retrive Data in a Particular Format

Hello, I have two tables. Employee Information and Skills Employee Information has the following details - ID (Unique Identifier), FirstName, LastName. Skills has the following details - Employee Id, Skillset A sample data will be as follows: Employee Information Id FirstName LastName 1 John ...

log only user queries in Postgres

Hi, I've enabled logging in my Postgres database (running on Ubuntu 32 bits) and I'd like to log only queries that a re performed by user applications. I've configured postgres as follows: log_destination = 'syslog' syslog_facility = 'L*emphasized text*OCAL0' syslog_ident = 'postgres' log_min_messages = notice log_min_duration_statement...

Advanced queries in HBase

Given the following HBase schema scenario (from the official FAQ)... How would you design an Hbase table for many-to-many association between two entities, for example Student and Course? I would define two tables: Student: student id student data (name, address, ...) courses (use course ids as column qualifiers h...

MySQL statement: spliting rows values into new columns

Using MySQL I need to return new first/last name columns for each user in table1. **Table1** uid 1 2 **Table2** id fid uid field_value 1 1 1 Joe 2 2 1 Blow 3 1 2 Joe 4 2 2 Blogs **Result** uid first_name last_name 1 Joe Blow 2 Joe Blogs ...

How to perform SQL query using Popel ORM in Symfony

Here is my problem, i'm trying to do tag cloud in symfony, what i want to perform is such a sql query select tag, count(tag) from tagi group by tag order by count(tag) desc limit 10 anyone can help? ...

Creating a loop that will edit 60 TextBox names?

text box set1 = 1 to 30 = in the query name = br1id to br30id textbox set 2 = 1 to 30 = in the result output i dont understand how to create a loop based on 30 diffrent textbox names? i cant copy paste these lines 30 times editing the textbox names, that wold just look wrong. try { MySqlConnection mysqlCon = new MySqlConnection...

Eager loading in Entity Framework fails on complex query

The following query fails to load the tables when I execute it: IEnumerable<Bookmark> tempBookmarks = ListBookmarksByUserID(userID); IEnumerable<CandidateWithBookmarks> results = (from c in _internshipEntities.CandidateSet .Include("education") .Incl...

Dynamic sql query

Hi there.. This is my query... but it returns incorrect syntax near '+' DECLARE @refKlinik_id INT SET @refKlinik_id = 24 DECLARE @kriter VARCHAR(50) IF @refKlinik_id <=0 BEGIN SET @kriter = '' END ELSE SET @Kriter = 'AND H.refKlinik_id =' + @refKlinik_id SELECT H.adi + ' ' + H.soyadi AS Hasta, H.tcKimlikNo, CONVERT(...

LINQ select problem

from item in db.Items join ci in db.ChainStoreItems on item.ItemId equals ci.ItemId where ci.ChainStoreId == 2 select item The problem is as follows: Item has a Set of ChainStoreItems. I want to make a qurey which returns a Item which dont have a Set of ChainStoreItems it should hold only the one specific ChainStoreItem for the select...

how to do a iterative rollup in sql

Hi I want to do a rolling sum (of valx) based on previous row value of rolling sum(valy) and the current row value of valx valy=previousrow_valy + valx animal valx valy cat 1 1 cat 3 4 cat 2 6 dog 4 4 dog 6 10 dog 7 17 dog 8 25 ...

ssrs combining rows into result set

So I have a sql server 2005 query that returns results like so: Address | Doctor ----------------------- 1 Dr A 1 Dr B 1 Dr C 2 NULL 3 NULL 4 Dr D 4 Dr E 5 Dr F What I want is to get the output so that when I render the report I have them grouped together: Dr A Dr B Dr C...

PHP display problems

I am pulling messages from mysql using PHP to be displayed on a specific page. Instead of displaying the title of the message in the designated title bar and the message in the designated body text box...there is no content displayed and its displaying the title in the url. What am I missing in my query? Or what is going on? ...

PHP display problems revisited

I am pulling messages from mysql using PHP to be displayed on a specific page. Instead of displaying the title of the message in the designated title bar and the message in the designated body text box...there is no content displayed and its displaying the title in the url. What am I missing in my query? Or what is going on? /*--Here is...

I need the most recent record in a join (PostgresSQL)

I have a table like so: call_activity ( call_id TEXT, activity_type TEXT, activity_time TIMESTAMP, PRIMARY KEY(call_id, activity_type, activity_time) ) activity_type may be one of about 9 different strings: 'started' 'completed' (about 5 variations on this) 'other' (these are the states that I want to display) A...