When I use Max to find the maximum value of a field in a particular MySQL Group after using GROUP BY, is it possible to get the entire row which contains the maximum value?
I am having trouble trying to convert the following query from SQL to Linq, in particular with the having count and group by parts of the query:
select ProjectID
from ProjectAssociation
where TeamID in ( select TeamID
from [User]
where UserID in (4))
group by ProjectID
having COUNT(TeamID) = (select distinct COUNT(TeamID)
from [User]
where UserID in (4))
Any advice on how to do so would be much appreciated.
For this example from the MongoDB documentation, how do I write the query using MongoTemplate?
db.sales.aggregate(
[
{
$group : {
_id : { month: { $month: "$date" }, day: { $dayOfMonth: "$date" }, year: { $year: "$date" } },
totalPrice: { $sum: { $multiply: [ "$price", "$quantity" ] } },
averageQuantity: { $avg: "$quantity" },
count: { $sum: 1 }
}
}
]
)
Or in general, how do I group by a calculated field?
Hi there
Just out of curiosity I was wondering how is it possible for the javascript code to embed google maps communicate with server from outside domain. I know I'm missing out something here. can anyone help?
thanks
gorup by query issue
i have one table,
which has three fields and data.
Name , Top , total
cat , 1 ,10
dog , 2, 7
cat , 3 ,20
hourse 4, 4
cat, 5,10
Dog 6 9
i want to select record which has highest value of "total" for each Name
so my result should be like this.
Name , Top , total
cat , 3 , 20
hourse , 4 , 4
Dog , 6 , 9
i tried group by name order by total, but it give top most record of group by result.
any one can guide me , please!!!!
I have an XML document based on a Schema that uses the xs:group element to bunch elements together.
The result is an entity
where name, address and phone number are defined in a group.
This fails Schema validation in MS (Visual Studio) as well as XERCES (oXygen XML editor)
Is there a workaround?
How can I do GroupBy Multiple Columns in LINQ
Something as in SQL :
SELECT * FROM <TableName> GROUP BY <Column1>,<Column2>
How Can i convert below to LINQ
QuantityBreakdown
(
MaterialID int,
ProductID int,
Quantity float
)
INSERT INTO @QuantityBreakdown (MaterialID, ProductID, Quantity)
SELECT MaterialID, ProductID, SUM(Quantity)
FROM @Transactions
GROUP BY MaterialID, ProductID
Thanks
I have one table, which has three fields and data.
Name , Top , Total
cat , 1 , 10
dog , 2 , 7
cat , 3 , 20
horse , 4 , 4
cat , 5 , 10
dog , 6 , 9
I want to select the record which has highest value of Total for each Name, so my result should be like this:
Name , Top , Total
cat , 3 , 20
horse , 4 , 4
Dog , 6 , 9
I tried group by name order by total, but it give top most record of group by result. Can anyone guide me, please?
I have to cs file for one partial class. I know that I can modify project file to group them together like way that vs.net group *.aspx and *.aspx.cs, but is there a way to do that in vs.net IDE directly?
When using the date and views module, you can specify in views (using row style fields) 'group multiple values'. Which is default on.
If you turn it off, you get multiple nodes each with a date. For example:
- 24th March ------- node1
- 25th March ------- node1
What I'm trying to figure out is: what if you are not using fields but node as Row style. How do you implement this not-group-multiple-values in your type-node.tpl.php?
i am building a simple PM for my personal website where a user can join and send message to the registered users on my website,
i am stuck in grouping and selecting latest user (by latest msg time) in INBOX page
my table :
id msg_from msg_to msg date in_del out_del
i want to show latest user's id each in a group
here is my SQL query :
SELECT ttalk.id, ttalk.msg_from, users.first_name, users.last_name
FROM ttalk
INNER JOIN users ON ttalk.msg_from = users.id
WHERE ttalk.msg_to = '$_SESSION[user_id]' AND ttalk.in_del='0'
GROUP BY ttalk.msg_from DESC LIMIT 500
Thanks in advance :-)
Is there an implementation with a blocking queue for take but bounded by a maximum size. However, when the maximum size is reached, instead of blocking, it will remove from the head.
One usage is that if I have a very slow consumer, the system will not crash ( runs out of memory ) rather these message will be removed.
I have 4 checkboxes added as a group so that I will be able to select only one checkbox.
But if I select one of them and now want to uncheck all of them in a group, I am unable to do that. Any one has idea how can I do that?
I need a query to return this result:
+---------+-----+-------+
| ref_nid | nid | delta |
+---------+-----+-------+
| AA | 97 | 1 |
| BB | 97 | 2 |
| CC | 97 | 3 |
| DD | 98 | 1 |
| EE | 98 | 2 |
| FF | 98 | 3 |
+---------+-----+-------+
However, I do not have the delta column. I need to generate it for each nid group.
In other words, I need an auto incremented number for each group of the result.
When I attempt to count the number of items in a group I get the total number of items in the collection. How do you get the number of items in each group?
Hi, All
I have read from some article that say's
Apple doesn't approve the application which Sell/Buy any physical items.
Is it correct or not ?
I am new to iPhone development.and don't know more details about Apples 's Policies.
Thanking in Advace...
I keep getting this error when I tried to execute this query, although I couldn't figure out what went wrong. I'm using Oracle and JDBC.
Here's the query:
SELECT Temp.flight_number, Temp.avgprice
FROM (SELECT P.flight_number, AVG (P.amount) AS avgprice
FROM purchase P
GROUP BY P.flight_number) AS Temp
WHERE Temp.avgprice = (SELECT MAX (Temp.avgprice)
FROM Temp)
I'm trying to get the maximum of average price of the tickets that customers have booked, group by flight_number.
I have the following two table scenario:
users
id groups
1 1,2,3
2 2,3
3 1,3
4 3
and
groups
id
1
2
3
How do I return the IDs of all users that belong to group 2 and 1 for example? Should I look into join, a helper group_membership table or function to separate the comma delimited group IDs to get something like this:
group_membership
user_id group_id
1 1
1 2
1 3
2 2
2 3
... ...
I'm having trouble getting my guest network up. I have VLAN 1 that contains all our network resources (servers, desktops, printers, etc). I have the wireless configured to use VLAN1 but authenticate with wpa2 enterprise. The guest network I just wanted to be open or configured with a simple WPA2 personal password on it's own VLAN2. I've looked at tons of documentation and it should be working but I can't even authenticate on the guest network!
I've posted this on cisco's support forum a week ago but no one has really responded. I could really use some help. So if anyone could take a look at the configurations I posted and steer me in the right direction I would be extremely grateful.
Thank you!
version 15.0
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname ESI
!
boot-start-marker
boot-end-marker
!
logging buffered 51200 warnings
!
aaa new-model
!
!
aaa authentication login userauthen local
aaa authorization network groupauthor local
!
!
!
!
!
aaa session-id common
!
!
!
clock timezone EST -5
clock summer-time EDT recurring
service-module wlan-ap 0 bootimage autonomous
!
crypto pki trustpoint TP-self-signed-3369945891
enrollment selfsigned
subject-name cn=IOS-Self-Signed-Certificate-3369945891
revocation-check none
rsakeypair TP-self-signed-3369945891
!
!
crypto pki certificate chain TP-self-signed-3369945891
certificate self-signed 01
(cert is here)
quit
ip source-route
!
!
ip dhcp excluded-address 192.168.1.1
ip dhcp excluded-address 192.168.1.5
ip dhcp excluded-address 192.168.1.2
ip dhcp excluded-address 192.168.1.200 192.168.1.210
ip dhcp excluded-address 192.168.1.6
ip dhcp excluded-address 192.168.1.8
ip dhcp excluded-address 192.168.3.1
!
ip dhcp pool ccp-pool
import all
network 192.168.1.0 255.255.255.0
default-router 192.168.1.1
dns-server 10.171.12.5 10.171.12.37
lease 0 2
!
ip dhcp pool guest
import all
network 192.168.3.0 255.255.255.0
default-router 192.168.3.1
dns-server 10.171.12.5 10.171.12.37
!
!
ip cef
no ip domain lookup
no ipv6 cef
!
!
multilink bundle-name authenticated
license udi pid CISCO891W-AGN-A-K9 sn FTX153085WL
!
!
username ESIadmin privilege 15 secret 5 $1$g1..$JSZ0qxljZAgJJIk/anDu51
username user1 password 0 pass
!
!
!
class-map type inspect match-any ccp-cls-insp-traffic
match protocol cuseeme
match protocol dns
match protocol ftp
match protocol h323
match protocol https
match protocol icmp
match protocol imap
match protocol pop3
match protocol netshow
match protocol shell
match protocol realmedia
match protocol rtsp
match protocol smtp
match protocol sql-net
match protocol streamworks
match protocol tftp
match protocol vdolive
match protocol tcp
match protocol udp
class-map type inspect match-all ccp-insp-traffic
match class-map ccp-cls-insp-traffic
class-map type inspect match-any ccp-cls-icmp-access
match protocol icmp
class-map type inspect match-all ccp-invalid-src
match access-group 100
class-map type inspect match-all ccp-icmp-access
match class-map ccp-cls-icmp-access
class-map type inspect match-all ccp-protocol-http
match protocol http
!
!
policy-map type inspect ccp-permit-icmpreply
class type inspect ccp-icmp-access
inspect
class class-default
pass
policy-map type inspect ccp-inspect
class type inspect ccp-invalid-src
drop log
class type inspect ccp-protocol-http
inspect
class type inspect ccp-insp-traffic
inspect
class class-default
drop
policy-map type inspect ccp-permit
class class-default
drop
!
zone security out-zone
zone security in-zone
zone-pair security ccp-zp-self-out source self destination out-zone
service-policy type inspect ccp-permit-icmpreply
zone-pair security ccp-zp-in-out source in-zone destination out-zone
service-policy type inspect ccp-inspect
zone-pair security ccp-zp-out-self source out-zone destination self
service-policy type inspect ccp-permit
!
!
crypto isakmp policy 1
encr 3des
authentication pre-share
group 2
!
crypto isakmp client configuration group 3000client
key 67Nif8LLmqP_
dns 10.171.12.37 10.171.12.5
pool dynpool
acl 101
!
!
crypto ipsec transform-set myset esp-3des esp-sha-hmac
!
crypto dynamic-map dynmap 10
set transform-set myset
!
!
crypto map clientmap client authentication list userauthen
crypto map clientmap isakmp authorization list groupauthor
crypto map clientmap client configuration address initiate
crypto map clientmap client configuration address respond
crypto map clientmap 10 ipsec-isakmp dynamic dynmap
!
!
!
!
!
interface FastEthernet0
!
!
interface FastEthernet1
!
!
interface FastEthernet2
!
!
interface FastEthernet3
!
!
interface FastEthernet4
!
!
interface FastEthernet5
!
!
interface FastEthernet6
!
!
interface FastEthernet7
!
!
interface FastEthernet8
ip address dhcp
ip nat outside
ip virtual-reassembly
duplex auto
speed auto
!
!
interface GigabitEthernet0
description $FW_OUTSIDE$$ES_WAN$
ip address 10...* 255.255.254.0
ip nat outside
ip virtual-reassembly
zone-member security out-zone
duplex auto
speed auto
crypto map clientmap
!
!
interface wlan-ap0
description Service module interface to manage the embedded AP
ip unnumbered Vlan1
arp timeout 0
!
!
interface Wlan-GigabitEthernet0
description Internal switch interface connecting to the embedded AP
switchport trunk allowed vlan 1-3,1002-1005
switchport mode trunk
!
!
interface Vlan1
description $ETH-SW-LAUNCH$$INTF-INFO-FE 1$$FW_INSIDE$
ip address 192.168.1.1 255.255.255.0
ip nat inside
ip virtual-reassembly
zone-member security in-zone
ip tcp adjust-mss 1452
crypto map clientmap
!
!
interface Vlan2
description guest
ip address 192.168.3.1 255.255.255.0
ip access-group 120 in
ip nat inside
ip virtual-reassembly
zone-member security in-zone
!
!
interface Async1
no ip address
encapsulation slip
!
!
ip local pool dynpool 192.168.1.200 192.168.1.210
ip forward-protocol nd
ip http server
ip http access-class 23
ip http authentication local
ip http secure-server
ip http timeout-policy idle 60 life 86400 requests 10000
!
!
ip dns server
ip nat inside source list 23 interface GigabitEthernet0 overload
ip route 0.0.0.0 0.0.0.0 10.165.0.1
!
access-list 23 permit 192.168.1.0 0.0.0.255
access-list 100 remark CCP_ACL Category=128
access-list 100 permit ip host 255.255.255.255 any
access-list 100 permit ip 127.0.0.0 0.255.255.255 any
access-list 100 permit ip 10.165.0.0 0.0.1.255 any
access-list 110 permit ip 192.168.0.0 0.0.5.255 any
access-list 120 remark ESIGuest Restriction
no cdp run
!
!
!
!
!
!
control-plane
!
!
alias exec dot11radio service-module wlan-ap 0 session
Access point
version 12.4
no service pad
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname ESIRouter
!
no logging console
enable secret 5 $1$yEH5$CxI5.9ypCBa6kXrUnSuvp1
!
aaa new-model
!
!
aaa group server radius rad_eap
server 192.168.1.5 auth-port 1812 acct-port 1813
!
aaa group server radius rad_acct
server 192.168.1.5 auth-port 1812 acct-port 1813
!
aaa authentication login eap_methods group rad_eap
aaa authentication enable default line enable
aaa authorization exec default local
aaa authorization commands 15 default local
aaa accounting network acct_methods start-stop group rad_acct
!
aaa session-id common
clock timezone EST -5
clock summer-time EDT recurring
ip domain name ESI
!
!
dot11 syslog
dot11 vlan-name one vlan 1
dot11 vlan-name two vlan 2
!
dot11 ssid one
vlan 1
authentication open eap eap_methods
authentication network-eap eap_methods
authentication key-management wpa version 2
accounting rad_acct
!
dot11 ssid two
vlan 2
authentication open
guest-mode
!
dot11 network-map
!
!
username ESIadmin privilege 15 secret 5 $1$p02C$WVHr5yKtRtQxuFxPU8NOx.
!
!
bridge irb
!
!
interface Dot11Radio0
no ip address
no ip route-cache
!
encryption vlan 1 mode ciphers aes-ccm
!
broadcast-key vlan 1 change 30
!
!
ssid one
!
ssid two
!
antenna gain 0
station-role root
!
interface Dot11Radio0.1
encapsulation dot1Q 1 native
no ip route-cache
bridge-group 1
bridge-group 1 subscriber-loop-control
bridge-group 1 block-unknown-source
no bridge-group 1 source-learning
no bridge-group 1 unicast-flooding
bridge-group 1 spanning-disabled
!
interface Dot11Radio0.2
encapsulation dot1Q 2
no ip route-cache
bridge-group 2
bridge-group 2 subscriber-loop-control
bridge-group 2 block-unknown-source
no bridge-group 2 source-learning
no bridge-group 2 unicast-flooding
bridge-group 2 spanning-disabled
!
interface Dot11Radio1
no ip address
no ip route-cache
shutdown
!
encryption vlan 1 mode ciphers aes-ccm
!
broadcast-key vlan 1 change 30
!
!
ssid one
!
antenna gain 0
dfs band 3 block
channel dfs
station-role root
!
interface Dot11Radio1.1
encapsulation dot1Q 1 native
no ip route-cache
bridge-group 1
bridge-group 1 subscriber-loop-control
bridge-group 1 block-unknown-source
no bridge-group 1 source-learning
no bridge-group 1 unicast-flooding
bridge-group 1 spanning-disabled
!
interface GigabitEthernet0
description the embedded AP GigabitEthernet 0 is an internal interface connecting AP with the host router
no ip address
no ip route-cache
!
interface GigabitEthernet0.1
encapsulation dot1Q 1 native
no ip route-cache
bridge-group 1
no bridge-group 1 source-learning
bridge-group 1 spanning-disabled
!
interface GigabitEthernet0.2
encapsulation dot1Q 2
no ip route-cache
bridge-group 2
no bridge-group 2 source-learning
bridge-group 2 spanning-disabled
!
interface BVI1
ip address 192.168.1.2 255.255.255.0
no ip route-cache
!
ip http server
no ip http secure-server
ip http help-path http://www.cisco.com/warp/public/779/smbiz/prodconfig/help/eag
access-list 10 permit 192.168.1.0 0.0.0.255
radius-server host 192.168.1.5 auth-port 1812 acct-port 1813 key *****
bridge 1 route ip
I'm trying to give permissions to a (sql 2005) database app based on AD groups. The general idea is to require a user to have a membership to "app_users" to view anything, and membership to other groups gives them write access to that group. "app_customers" gives write access to the customers module, "app_sales" to sales, etc.
I've listed an example below:
user1: AD member of app_users
user2: AD member of app_users, app_customers
For dbo.customers table:
app_users
- Granted: Select permission
- Denied: Insert, Update, Delete
app_customers
- Granted: Select permission
- Granted: Insert, Update, Delete
I would expect user1 to be able to view the dbo.customers table, but will not be allowed to modify anything (insert/update/delete) - which works. In the same vein, I would expect user2 to be able to view AND modify the dbo.customers table, since they are a member of app_customers.
However, this is not the case. Instead, user2 is denied any modifications just like user1. I seem to remember something about deny permissions winning if there was a conflict, but it's honestly been too long since I've dealt with them.
Am I going about this the right way?
Thanks for your time!
I had two HDDs, each one containing a LVM partition which formed a volume group. Then I had two LVs, one for my / directory and one for my /home/ directory. Yesterday where I had my / dir failed. I'm trying to recover at least my /home/ dir.
What I've done so far:
Boot a live system
Extract LVM2 metadata from the working HDD using dd
Copy metadata to /etc/lvm/backup/vg0
Now I'm trying to do this:
pvcreate --restore /etc/lvm/backup/vg0 --uuid "[uuid of my working hdd]" /dev/sdb2
But I always get:
Couldn't find device with uuid '[uuid of broken hdd]'.
Couldn't find device with uuid '[uuid of working hdd]'.
Device /dev/sdb2 not found (or ignored by filtering).
I confirmed that /dev/sdb2 exists and I've commented out all filtering settings from /etc/lvm/lvm.conf so I don't know what might be causing pvcreate not to find the device.
So:
What might be the problem?
Is it even possible to restore this partition? (As I'm writing this I'm starting to think it's impossible D:)
Edit: Okay, looks like I've got it figured out. I was using a Ubuntu 8.10 CD (yeah, I know it's not supported anymore) and it seems that was the problem. When I started from a Ubuntu 10.04 CD everything worked 'fine', I could mount my LVM partitions partially without problems. (Will answer the question in 4 hours. But if anyone has still got some hints/tips, please share! :)
I have a Volume Group with Unused space. This 40Gig should become an entidy in order to install Microsoft windows 7 on it. I do not have extra space on the drive - that is why I want to shrink the VG!
LVG berta resides on sda2 and consists of
lv_root
lv_swap
unused_space
I want it to become
lv_root
lv_swap
and have a seperate entidy made out of unused_space. Microsoft Windows 7 has to get installed on this entidy. I do not understand why Linux made simple things complicated. I utterly hate LVM and think its absolute bollocks.
Useful Sources:
http://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-system-config-lvm.html
Edit: I found the answer. The necessary steps depict how complicated LVM really is. In my opinion it is best to avoiding LVM until pvresize matures as promised in its man pages.
Answer:
http://fedorasolved.org/Members/zcat/shrink-lvm-for-new-partition
If you run into problems when you want to remove lvswap even if in resuce mode, then try
swapoff /dev/vg_1/lv_swap
lvchange -an /dev/vg_1/lv_swap
I have active directory sign in working on an Ubuntu 12.04 box. When the user signs in, I have a script that runs that needs sudo permission (since it modifies the samba config file). How would I specify this in my sudoer's file?
I've tried:
%DOMAIN\\AD+Programmers ALL=NOPASSWD: /usr/local/bin/createSambaShare.php
I've found various resources on the internet stating that this is how it would be done, but I'm not sure that I have the first part right. What are they using as the DOMAIN? The workgroup or the realm?
I use Samba + winbind for active directory integration. Here's my smb.conf:
[global]
security = ads
netbios name = hostname
realm = COMPANYNAME.COM
password server = passwordserver
workgroup = COMPANYNAME
idmap uid = 1000-10000
idmap gid = 1000-10000
winbind separator = +
winbind enum users = no
winbind enum groups = no
winbind use default domain = yes
template homedir = /home/%D/%U
template shell = /bin/bash
client use spnego = yes
domain master = no
EDIT: The users that should have access to run that script are all part of the Programmers group which has an Active Directory Domain Services Folder of Company.com/Staff/Security Groups (not sure if that matters or not).
I have a development git server that deploys to a live server when the live branch is pushed to.
Every user has their own login and therefore the post-receive hook which does the live deployment is run under their own user.
Because I don't want to have to maintain the users public keys as authorized keys on the remote live server I have made up a set of keys that 'belong's to the git system to add to remote live servers (In the post-receive hook I am using $GIT_SSH to set the private key with the -i option).
My problem is that because of all the users might want to deploy to live, the git system's private key has to be at least group readable and SSH really doesn't like this.
Here's a sample of the error:
XXXX@XXXX /srv/git/identity % ssh -i id_rsa XXXXX@XXXXX
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0640 for 'id_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: id_rsa
I've looked around expecting to find something in the way of forcing ssh to just go through with the connection but I've found nothing but people blindly saying that you just shouldn't allow access to anything but a single user.