Hello all. I was wondering if someone could write me out a statement for some data I am listing below. I need some expertise on how to get the correct output and if it can be done to begin with.
3 table fields
name (varchar) , n1 (varchar) , n2(varchar)
and some data
name rick
n1 t5:t5
n2 192.168.0.1
name rick
n1 t5:t5
n2 192.168.0.2
name rick
n1 t1:t1
n2 192.168.0.1
name: not rick
n1. t1.t1
n2 192.168.0.2
how can i setup a statement where I match all four of these entries and have all these entries grouped by name.
Somehow query all matches in n1 or n2
all four entries have a shared entry by either n1 or n2 but i need the slq statement to group all of these.
Also, is there anyway to order by name by having the most common name as an entry? For example, rick is listed 3 times while not rick is listed once. Even if they are grouped, I would like to have the grouped name outputted as whatever is listed the most
sql=select max(name) as usethisname , name, n1,n2 from table
group by name having n1=n1 OR n2=n2
order by usethisname