question about selecting records

Discussion in 'Databases' started by Scott, Jan 12, 2005.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. SELECT Agent, CheckInDate, Count(ID) As Records FROM Table1 GROUP BY Agent, CheckInDate
     
  2. I have a mssql database like this:

    Table1:
    ID GuestName Agent CheckInDate OtherColumn
    1Guest 1 Peter 1/11/2005 whatever
    2 Guest 2 Peter 1/11/2005whatever
    3 Guest 3 John 1/11/2005whatever
    4 Guest 4 John 1/13/2005 whatever
    5 Guest 5 Peter 1/11/2005 whatever

    I want to display itgroup by sameAgent and CheckInDate. Like this:

    Agent CheckInDate Records
    Peter 1/11/2005 3
    John 1/11/2005 1
    John 1/13/2005 1

    How can I do this? Please help, thank you.
     
  3. Thanks Scott, I got that. There's another problem now.

    I put these data into a DataGrid. I want to give each row a link, which will link to "page_detail.aspx", andI want "Agent" and "CheckInDate" to be the parameter. So it should be like "page_detail.aspx?agent=Peter&checkindate=1/11/2005". I was trying to use HyperLinkColumn, but since the parameters aretext in DataGridcells,i don't know how to put the paramters on.
     
  4. another question. The actual CheckInDate values has time value in it. for example, 1/11/2005 1:15:45PM. If I use GROUP BY CheckInDate, the time value matters. How can ingore time value and just GROUP BY date value?
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page