Search Results

Search found 13523 results on 541 pages for 'group selection'.

Page 9/541 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Mysql query different group by

    - by solomongaby
    Hello i have a products table that contains normal products and configurable product It has a basic stucture of: id name price configurable ('yes', 'no') id_configuration Normal products have configurable no and 0 as id configuration, and configurable products have it set to yes and have the same id_configuration value. The current query is: SELECT `products`.* FROM `products`, `categories`, `product_categories` WHERE `categories`.`id` = 23 AND `products`.`id` = `product_categories`.`id_product` AND `categories`.`id` = `product_categories`.`id_category` AND `products`.`active` = 'yes' AND ORDER BY `pos_new` ASC, `created` DESC LIMIT 0,20 I was wondering if there is a way to group by id_configuration, but only for the configurable products. The reason is that i want only one of the configuration products to show in search. I was thinking i could do a join, but was wondering if there is a way to do some kind of special group by. For example for configurable yes the field should be id_configuration otherwise it should be the id field Thanks a lot for any sugestions

    Read the article

  • SQL: GROUP BY after JOIN without overriding rows?

    - by krismeld
    I have a table of basketball leagues, a table af teams and a table of players like this: LEAGUES ID | NAME | ------------------ 1 | NBA | 2 | ABA | TEAMS: ID | NAME | LEAGUE_ID ------------------------------ 20 | BULLS | 1 21 | KNICKS | 2 PLAYERS: ID | TEAM_ID | FIRST_NAME | LAST_NAME | --------------------------------------------- 1 | 21 | John | Starks | 2 | 21 | Patrick | Ewing | Given a League ID, I would like to retrieve all the players' names and their team ID from all the teams in that league, so I do this: SELECT t.id AS team_id, p.id AS player_id, p.first_name, p.last_name FROM teams AS t JOIN players AS p ON p.team_id = t.id WHERE t.league_id = 1 which returns: [0] => stdClass Object ( [team_id] => 21 [player_id] => 1 [first_name] => John [last_name] => Starks ) [1] => stdClass Object ( [team_id] => 21 [player_id] => 2 [first_name] => Patrick [last_name] => Ewing ) + around 500 more objects... Since I will use this result to populate a dropdown menu for each team containing each team's list of players, I would like to group my result by team ID, so the loop to create these dropdowns will only have to cycle through each team ID instead of all 500+ players each time. But when I use the GROUP BY like this: SELECT t.id AS team_id, p.id AS player_id, p.first_name, p.last_name FROM teams AS t JOIN players AS p ON p.team_id = t.id WHERE t.league_id = 1 GROUP BY t.id it only returns one player from each team like this, overriding all the other players on the same team because of the use of the same column names. [0] => stdClass Object ( [team_id] => 21 [player_id] => 2 [first_name] => Patrick [last_name] => Ewing ) [1] => stdClass Object ( [team_id] => 22 [player_id] => 31 [first_name] => Shawn [last_name] => Kemp ) etc... I would like to return something like this: [0] => stdClass Object ( [team_id] => 2 [player_id1] => 1 [first_name1] => John [last_name1] => Starks [player_id2] => 2 [first_name2] => Patrick [last_name2] => Ewing +10 more players from this team... ) +25 more teams... Is it possible somehow?

    Read the article

  • SQL GROUP BY with "default values"

    - by Christoph Schiessl
    I'm trying to create SELECT statement with a GROUP BY clause, which should return "default values". Imagine the following simple MySQL table: CREATE TABLE `tracker` ( `id` INTEGER PRIMARY KEY auto_increment, `date` DATETIME NOT NULL, `customer_id` INTEGER NOT NULL ); The table contains only one record: INSERT INTO `tracker` (`date`, `customer_id`) VALUES('2010-05-03', 1); After wards I'm executing the following SQL query: SELECT DATE(`date`), COUNT(customer_id) FROM tracker WHERE DATE(`date`) >= '2010-05-01' AND DATE(`date`) <= '2010-05-05' GROUP BY DATE(`date`) ORDER BY DATE(`date`); And get the expected result set: +----+---------------------+-------------+ | id | date | customer_id | +----+---------------------+-------------+ | 1 | 2010-05-10 00:00:00 | 1 | +----+---------------------+-------------+ However, I would like the result set to look like this: +--------------+--------------------+ | DATE(`date`) | COUNT(customer_id) | +--------------+--------------------+ | 2010-05-01 | 0 | | 2010-05-02 | 0 | | 2010-05-03 | 1 | | 2010-05-04 | 0 | | 2010-05-05 | 0 | +--------------+--------------------+ Is it possible to achieve this behavior?

    Read the article

  • Determining Cross Domain Active Directory Group Membership

    - by thecaptain0220
    I am currently working on a project where I need to query Active Directory to determine group membership of a user. I initially was locating the user and retrieving the memberOf attribute. The problem with this is that there is a domain and a child domain. The groups are universal groups so they can be used in both domains and they don't show up in the memberOf attribute. Unfortunately there doesn't seem to be much info around for Active Directory access with C++. Is there anyway to determine group membership in this case in C++?

    Read the article

  • Nhibernate linq group by duplicate fields

    - by jaspion
    Hello, I have a simple query like: from e in endContratoRepository.GetAll() where e.Contrato.idContrato == contrato.idContrato && e.Volume.idVolume == 1 && group e by new { e.dpto.idDepartamento, e.centroCusto.idCentroCusto } into grp select new Entidade { Contagem = grp.Count(), centroCusto = grp.Key.idCentroCusto, dpto = grp.Key.idDepartamento } and the problem: The fields that are in the group by, are duplicated in the generated query. The fields centroCusto and dpto appears twice, so when I try to get the field centroCusto, I get dpto. Anyone know how to solve this? thanks a lot!

    Read the article

  • MySQL GROUP BY with three tables

    - by Psaniko
    I have the following tables: posts (post_id, content, etc) comments (comment_id, post_id, content, etc) posts_categories (post_category_id, post_id, category_id) and this query: SELECT `p`.*, COUNT(comments.comment_id) AS cmts, posts_categories.*,comments.* FROM `posts` AS `p` LEFT JOIN `posts_categories` ON `p`.post_id = `posts_categories`.post_id LEFT JOIN `comments` ON `p`.post_id = `comments`.post_id GROUP BY `p`.`post_id` There are three comments on post_id=1 and four in total. In posts_categories there are two rows, both assigned to post_id=1. I have four rows in posts. But if I query the statement above I get a result of 6 for COUNT(comments.comment_id) at post_id=1. How is this possible? I guess the mistake is somewhere in the GROUP BY clause but I can't figure out where. Any suggestions?

    Read the article

  • SELECT * , COUNT( * ) FROM GROUP BY ORDER BY DESC

    - by quanganh_developer
    I have a table like: gold gold_city | gold_type | gold_selltime ------------------------------------- city1 | type 1 | 2012-01-01 city1 | type 1 | 2012-02-02 city1 | type 1 | 2012-03-03 city2 | type 2 | 2012-01-01 city2 | type 2 | 2012-02-02 city2 | type 2 | 2012-03-03 city3 | type 3 | 2012-01-01 city3 | type 3 | 2012-02-02 city3 | type 3 | 2012-03-03 How can I get 1 last result order by gold_selltime desc each group by gold_city and gold_type I used this: SELECT * , COUNT( * ) FROM gold_2012 GROUP BY gold_type , gold_city ORDER BY gold_selltime DESC but it did work. I only have result like: gold_city | gold_type | gold_selltime ------------------------------------- city1 | type 1 | 2012-01-01 city2 | type 2 | 2012-01-01 city3 | type 3 | 2012-01-01 but I need it like: gold_city | gold_type | gold_selltime ------------------------------------- city1 | type 1 | 2012-03-03 city2 | type 2 | 2012-03-03 city3 | type 3 | 2012-03-03

    Read the article

  • Concatenate and group multiple rows in Oracle

    - by user1693347
    Suppose I have a table like this: NAME GROUP name1 groupA name2 groupB name5 groupC name4 groupA name3 groupC I'd like to have a result like this: GROUP NAMES groupA name1,name4 groupB name2 groupC name3,name5 If there were only one column in the table, I could concatenate the records by doing the following, but with grouping in the context, I really don't have much idea. Any suggestion is welcome, thanks in advance! Concatatenating one column table: SELECT names FROM (SELECT SYS_CONNECT_BY_PATH(names,' ') names, level FROM name_table START WITH names = (SELECT names FROM name_table WHERE rownum = 1) CONNECT BY PRIOR names < names ORDER BY level DESC) WHERE rownum = 1

    Read the article

  • Grouping by property value and writing group members

    - by Will S
    I need to group the following list by the department value but am having trouble with the LINQ syntax. Here's my list of objects: var people = new List<Person> { new Person { name = "John", department = new List<fields> {new fields { name = "department", value = "IT"}}}, new Person { name = "Sally", department = new List<fields> {new fields { name = "department", value = "IT"}}}, new Person { name = "Bob", department = new List<fields> {new fields { name = "department", value = "Finance"}}}, new Person { name = "Wanda", department = new List<fields> {new fields { name = "department", value = "Finance"}}}, }; I've toyed around with grouping. This is as far as I've got: var query = from p in people from field in p.department where field.name == "department" group p by field.value into departments select new { Department = departments.Key, Name = departments }; So can iterate over the groups, but not sure how to list the Person names - foreach (var department in query) { Console.WriteLine("Department: {0}", department.Department); foreach (var foo in department.Department) { // ?? } } Any ideas on what to do better or how to list the names of the relevant departments?

    Read the article

  • How to adjust a single side of rectangular selection made with Marquee Tool?

    - by Alex
    I am struggling to make a selection made of different layers. For example, a button with text and shadow (each in its own layer). I would like to copy it to a image file but it is really hard to select the shadow with a pixel precision. I do not know how to perform such task properly so I use Marquee Tool. However, it is hard to get all 4 sides right from the first attempt. What's worse, I could not find a method to adjust a single side of a selection made by Marquee Tool. Anyone may help what I am doing wrong?

    Read the article

  • translate stored procedure - to Linq2SQL (count, max, group, orderby)

    - by Walter
    I've two tables (1:N) CREATE TABLE master (idMaster int identity (1,1) not null, TheName varchar( 100) null, constraint pk_master primary key(idMaster) clustered) and - CREATE TABLE lnk (idSlave int not null, idMaster int not null, constraint pk_lnk_master_slave(idSlave) primary key clustered) link between Master.idMaster and lnk.idMaster I've a SQL query: select max (master.idMaster) as idMaster, master.theName, count (lnk.idSlave) as freq from lnk inner join master ON lnk.idMaster = master.idMaster Group by master.theName order by freq desc, master.theName I need to translate this T-SQL query to a Linq-to-SQL statement, preferably in C#

    Read the article

  • Better way to do SELECT with GROUP BY

    - by Luca Romagnoli
    Hi i've wrote a query that works: SELECT `comments`.* FROM `comments` RIGHT JOIN (SELECT MAX( id ) AS id, core_id, topic_id FROM comments GROUP BY core_id, topic_id order by id desc) comm ON comm.id = comments.id LIMIT 10 I want know if it is possible (and how) to rewrite it to get better performance. Thanks

    Read the article

  • cakePHP and GROUP BY

    - by Lizard
    I am trying to solve a hopefully simple problem here is the query I am trying produce: SELECT `categories`.*, COUNT(`entities`.id) FROM `categories` LEFT JOIN `entities` ON (`categories`.`id` = `entities`.`category_id`) GROUP BY `categories`.`id` I am really struggling to do this is in cakePHP 1.2 How would/should I go about doing this... (I am using 'Containable' if that helps) Thanks in advance

    Read the article

  • How to create entities in one Entity group ?

    - by Gopi
    I am building an app based on google app engine (Java) using JDO for persistence. Can someone give me an example or a point me to some code which shows persisting of multiple entities (of same type) using javax.jdo.PersistenceManager.makePersistentAll() within a transaction. Basically I need to understand how to put multiple entites in one Entity Group so that they can be saved using makePersistentAll() inside transaction.

    Read the article

  • GROUP BY a date, with ordering by date.

    - by standard
    Take this simple query: SELECT DATE_FORMAT(someDate, '%y-%m-%d') as formattedDay FROM someTable GROUP BY formatterDay This will select rows from a table with only 1 row per date. How do I ensure that the row selected per date is the earliest for that date, without doing an ordered subquery in the FROM? Cheers

    Read the article

  • MYSQL Select statment Order By with Group By

    - by mouthpiec
    I have the following simple SQL statment SELECT id, name, value_name, value_id FROM table GROUP BY id ORDER BY value_id DESC when grouping I would like to get the value_name and value_id of the tuple where the value_id is the biggest. The way it is i am getting the smallest value. For example 1, name1, valuename, 3 (where i know that there is a value_id of 5) Can you please help?

    Read the article

  • Better mode for do a select with group by

    - by Luca Romagnoli
    Hi i've wrote a query that works: SELECT `comments`.* FROM `comments` RIGHT JOIN (SELECT MAX( id ) AS id, core_id, topic_id FROM comments GROUP BY core_id, topic_id order by id desc) comm ON comm.id = comments.id LIMIT 10 I want know if is possible and how rewrite it for get better performance. thanks

    Read the article

  • sql - getting the id from a row based on a group by

    - by user85116
    Table A tableAID tableBID grade Table B tableBID name description Table A links to Table b from the tableBID found in both tables. If I want to find the row in Table A, which has the highest grade, for each row in Table B, I would write my query like this: select max(grade) from TableA group by tableBID However, I don't just want the grade, I want the grade plus id of that row.

    Read the article

  • MySQL: group by and IF statement

    - by notset
    By default, parent_id = 0. I want to select all records with parent_id = 0 and only the last ones with parent_id 0. I tried this, but it didn't work: SELECT * FROM `articles` IF `parent_id` > 0 THEN GROUP BY `parent_id` HAVING COUNT(`parent_id`) >= 1 END; ORDER BY `time` DESC What could be the solution?

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >