I'm using a query, I want to group them by 1 specific column. i get an error for other field witch are not listed in GROUP BY clause, yes i know i should tell Sql Server witch row of grouped by rows you should pick but i don't know how to do that. If that's int i use MIN() function and if its a text field i don't know what to do. I want to select all data and if videos.number,videos.title is replicated than get the first row of grouped rows. What this query do is: get all channels from packages according to client subscription. sometime different packages have same channels and I don't want this channel to be shown twice to client.
USE [DB]
 SELECT Videos.number,
        Videos.title,
        Videos.description,
        Videos.format,
        Videos.urlTwo AS url,
        Videos.icon,
        Videos.streamtype,
        'pin' AS password,
        Videos.categoryid,
        Videos.videotype,
   FROM subscription
        INNER JOIN packages_channels
            ON subscription.pkgid = packages_channels.package_id 
        INNER JOIN Videos 
            ON packages_channels.video_id = Videos.number
  WHERE (GETDATE() >= subscription.startdate) 
    AND (GETDATE() <= subscription.enddate) 
    AND (subscription.username = 'mon1')
  GROUP BY videos.number, Videos.title
  ORDER BY Videos.number asc
this is what it shows right now:
number  title        description  format    url                      icon 
101     channel1     101          101       URLstream1               iconPath1
101     channel1     101          101       URLstream1               iconPath1  
102     channel2     101          102       URLstream2               iconPath2
107     channel7     107          107       URLstream7               iconPath7
108     channel8     108          108       URLstream8               iconPath8
but the result i want to get is this:
   number  title        description  format    url                      icon 
    101     channel1     101          101       URLstream1               iconPath1  
    102     channel2     101          102       URLstream2               iconPath2
    107     channel7     107          107       URLstream7               iconPath7
    108     channel8     108          108       URLstream8               iconPath8
as you see channel1 its only once url,and icon is the problem. this fields are text
I can't show a real sql result for security reason.
 
     
     
     
    